-
Notifications
You must be signed in to change notification settings - Fork 625
HDDS-15723. Ignore writes after PutBlock with end-of-block flag #10967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
bfb9794
454ba4f
6c03b7d
a2e735d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -205,10 +205,17 @@ public long persistPutBlock(KeyValueContainer container, | |||
| return data.getSize(); | ||||
| } | ||||
|
|
||||
| // Check if the block is present in the pendingPutBlockCache for the | ||||
| // container to determine whether the blockCount is already incremented | ||||
| // for this block in the DB or not. | ||||
| long localID = data.getLocalID(); | ||||
|
|
||||
| // PutBlock is not idempotent; ignore duplicate eof writes (HDDS-12007). | ||||
| if (container.isBlockFinalizedByEof(localID)) { | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check may be too late for a piggybacked Line 1131 in a2e735d
The data may therefore already be changed when this check skips the metadata update. Could the finalized-state check happen before chunk processing as well? |
||||
| LOG.warn("Ignoring write on block {} which has already been finalized " | ||||
| + "by a PutBlock with the end-of-block flag set. PutBlock is not " | ||||
| + "idempotent", | ||||
| data.getBlockID()); | ||||
| return data.getSize(); | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This skips the |
||||
| } | ||||
|
|
||||
| // For the PutBlock that is endOfBlock and meanwhile bscId = 0, it means | ||||
| // this PutBlock comes from data stream close without going through the | ||||
| // Raft, thus there is no log index. In this case, we should not let | ||||
|
|
@@ -223,6 +230,10 @@ public long persistPutBlock(KeyValueContainer container, | |||
| data.setBlockCommitSequenceId(bcsId); | ||||
| } | ||||
| } | ||||
|
|
||||
| // Check if the block is present in the pendingPutBlockCache for the | ||||
| // container to determine whether the blockCount is already incremented | ||||
| // for this block in the DB or not. | ||||
| boolean isBlockInCache = container.isBlockInPendingPutBlockCache(localID); | ||||
| boolean incrBlockCount = false; | ||||
|
|
||||
|
|
@@ -294,6 +305,13 @@ public long persistPutBlock(KeyValueContainer container, | |||
| container.removeFromPendingPutBlockCache(localID); | ||||
| } | ||||
|
|
||||
| // Track the block as finalized so that any subsequent write on it can be | ||||
| // detected and ignored, since PutBlock is not idempotent. Only OPEN and | ||||
| // CLOSING containers maintain eofBlockCache. | ||||
| if (endOfBlock && (containerData.isOpen() || containerData.isClosing())) { | ||||
| container.addToEofBlockCache(localID); | ||||
| } | ||||
|
|
||||
| if (LOG.isDebugEnabled()) { | ||||
| LOG.debug( | ||||
| "Block " + data.getBlockID() + " successfully committed with bcsId " | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This state is lost when a replica restarts. A later Raft entry could then be skipped by replicas that retained the cache but persisted by the restarted replica. Could the EOF state be persisted and restored with the container?