Skip to content

HDDS-16757. RenameKeys overwrites an existing destination key and still reports the pair as not renamed - #11438

Draft
smengcl wants to merge 1 commit into
apache:masterfrom
smengcl:HDDS-16757-renamekeys
Draft

smengcl wants to merge 1 commit into
apache:masterfrom
smengcl:HDDS-16757-renamekeys

Conversation

@smengcl

@smengcl smengcl commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Generated-by: Claude Code (Opus 5.5)

What changes were proposed in this pull request?

In OMKeysRenameRequest#validateAndUpdateCache, the "Check if toKey exists" block marks the pair as not renamed but does not continue, unlike the other checks in the same loop. A batch rename onto an existing key therefore still renames the source key over the destination key:

  • The destination row is replaced in the key table and its blocks are never added to the deleted table, so they are leaked.
  • The response is PARTIAL_RENAME and lists the same pair in unRenamedKeys, so the client is told that the rename did not happen.
  • If the source key does not exist either, the pair is listed twice in unRenamedKeys.

This PR adds the missing continue, so the pair is skipped and both keys are left unchanged. This matches the single key rename (OMKeyRenameRequest), which rejects the same case with KEY_ALREADY_EXISTS.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16757

How was this patch tested?

Added TestOMKeysRenameRequest#testKeysRenameRequestToExistingKey. It batch renames one existing key onto another, together with a pair whose source key is missing, and asserts that the status is PARTIAL_RENAME, that each pair is listed exactly once in unRenamedKeys, and that both key table rows are unchanged. The test fails without the fix.

🤖 Generated with Claude Code

…ll reports the pair as not renamed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 17:34
@smengcl smengcl added bug Something isn't working AI-gen labels Oct 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow fix and regression assertions address the reported defect with no identified blocking issues; tests were not executed.

0 open findings

What changed in this PR

Fixes OM batch rename handling so an existing destination key is preserved and each rejected pair is reported only once.

Changes:

  • Skip rename processing when the destination already exists.
  • Add regression coverage for unchanged keys and accurate failure reporting.
File Description
hadoop-ozone/​ozone-manager/​src/​test/​java/​org/​apache/​hadoop/​ozone/​om/​request/​key/​TestOMKeysRenameRequest.java Tests destination preservation and single reporting of rejected pairs.
hadoop-ozone/​ozone-manager/​src/​main/​java/​org/​apache/​hadoop/​ozone/​om/​request/​key/​OMKeysRenameRequest.java Adds the missing continue for existing destinations.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot added the om label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-gen bug Something isn't working om

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants