smengcl opened a new pull request, #11780:
URL: https://github.com/apache/ozone/pull/11780

   Generated-by: Claude Code (Opus 5.5)
   
   ## What changes were proposed in this pull request?
   
   `OMKeysRenameRequest.validateAndUpdateCache` checks each pair against the 
key table, whose cache already holds the result of the earlier pairs of the 
same transaction, and stores the accepted pairs in a `HashMap` from source name 
to the new `OmKeyInfo`. `OMKeysRenameResponse.addToDBBatch` iterates that map 
and writes, per entry, a delete of the source and a put of the destination. 
When pairs of one transaction share key names, the batch depends on the map's 
iteration order, and a source named twice keeps only its last pair. The 
committed key table then differs from the cache: depending on the names, a key 
is committed twice on the same blocks, or a key reported as renamed disappears 
and its blocks leak. Once the cache entries are evicted after the flush, or on 
restart, the committed state is what every read sees.
   
   This change makes `OMKeysRenameRequest.preExecute` reject the transaction 
with `INVALID_REQUEST` when a pair names a key that an earlier pair of the same 
transaction uses as source or destination. Pairs with an empty name are 
skipped, as `validateAndUpdateCache` never applies them. The check needs only 
the key names, so it runs on the leader before the transaction is replicated. 
`validateAndUpdateCache` and the response are unchanged, so entries already in 
the Raft log are applied as before.
   
   Behaviour change: such a transaction is now rejected as a whole and nothing 
in it is renamed. For some key names it commits correctly today (for example 
`k` to `k_b`, then `k_b` to `k_c`); those are rejected too. Transactions whose 
pairs share no key behave as before.
   
   Keeping the pairs in their original order in the response was considered and 
not taken: the map keyed by source name loses the earlier of two pairs with one 
source, so it would need an ordered list of pairs passed from the request to 
the response, a larger change of both.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-17469
   
   ## How was this patch tested?
   
   - New parameterized 
`TestOMKeysRenameRequest.testCommittedKeyTableMatchesCache`: runs a transaction 
through `preExecute` and `validateAndUpdateCache`, commits its response, and 
compares each key in the DB with the cache. Two cases with pairs that share a 
key must be rejected with `INVALID_REQUEST`; a case with disjoint pairs is the 
control. Without the change both shared key cases fail (`key_b` present in the 
DB but not in the cache; `key` present in the cache but not in the DB).
   - `TestOMKeysRenameRequest`, `TestOMKeysRenameResponse`, 
`TestOMKeyRenameRequest`, `TestOMKeyRenameRequestWithFSO`, 
`TestOMKeyRenameResponse` and `TestOMKeyRenameResponseWithFSO` (36 tests) pass 
locally on master; checkstyle is clean.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to