Skip to content

HDDS-16844. Remove duplicate overwrite checks in ChunkUtils - #11465

Merged
peterxcli merged 1 commit into
apache:masterfrom
peterxcli:HDDS-16844
Oct 11, 2026
Merged

peterxcli merged 1 commit into
apache:masterfrom
peterxcli:HDDS-16844

Conversation

@peterxcli

@peterxcli peterxcli commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

cleanup after #11150

With this change:

  • ChunkUtils keeps a single validateChunkForOverwrite(long fileLen, ChunkInfo), with the info.getOffset() < fileLen check written inline.
  • Both isOverWriteRequested overloads are removed. Nothing outside ChunkUtils called them.
  • FilePerChunkStrategy.writeChunk passes chunkFile.length() to the long version.

This does not change behavior for real requests. File.length() returns 0 for a file that does not exist, so the old exists() check made no difference for any offset of 0 or more. File.length() also returns 0 on an I/O error, which the old code already relied on. As a side effect, each write in the FilePerChunk layout does one fewer file system call.

The only input that behaves differently is a negative offset on a chunk file that does not exist yet. It now counts as an overwrite, where before it did not. The offset is a uint64 on the wire, and FilePerBlockStrategy already treats this case the same way.

What is the link to the Apache JIRA

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

How was this patch tested?

TestChunkUtils.validateChunkForOverwrite now checks only the long method. Its file-based asserts used the same length and offsets as the long cases that were already there.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 13:42

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@peterxcli
peterxcli marked this pull request as ready for review October 10, 2026 13:43

@chihsuan chihsuan 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.

Thanks for the patch! @peterxcli LGTM +1

public static boolean validateChunkForOverwrite(long fileLen, ChunkInfo info) {

if (isOverWriteRequested(fileLen, info)) {
if (info.getOffset() < fileLen) {

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.

Not related to this PR, but I noticed that comparing file length with the block-relative offset may miss overwrites in chunks after the first. Filed HDDS-16874 as a follow-up.

@peterxcli
peterxcli merged commit 6c46be9 into apache:master Oct 11, 2026
74 checks passed
@peterxcli

Copy link
Copy Markdown
Member Author

@chihsuan thanks for the filing followup and merging!

@peterxcli
peterxcli deleted the HDDS-16844 branch October 11, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants