Skip to content

HDDS-16452. Fix inconsistent SCM checkpoints during transaction apply - #11837

Open
F64116045 wants to merge 1 commit into
apache:masterfrom
F64116045:HDDS-16452
Open

F64116045 wants to merge 1 commit into
apache:masterfrom
F64116045:HDDS-16452

Conversation

@F64116045

@F64116045 F64116045 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

SCM flushes the transaction buffer before serving a DB checkpoint.
If a checkpoint download overlaps Ratis transaction apply, flush() can commit the data for index N before the recorded transaction index is updated from N-1 to N. The checkpoint then contains data through N but records N-1.

This PR uses flushIfNeeded(0) to skip the flush while a transaction is being applied.
A slightly stale but consistent checkpoint is safe, as the follower can catch up through Ratis log replay.

Before

Ratis apply path                         gRPC checkpoint path
----------------                         --------------------

beginApplyingTransaction()

addToBuffer(dataForIndexN)
// latestTrxInfo is still N-1
                                         download()
                                           flush()
                                             putWithBatch(transactionInfo, N-1)
                                             commitBatchOperation()
                                           checkpoint:
                                             index N-1 + data through N
                                             inconsistent

updateLatestTrxInfo(N)
endApplyingTransaction()
After

Ratis apply path                         gRPC checkpoint path
----------------                         --------------------

beginApplyingTransaction()

addToBuffer(dataForIndexN)
// latestTrxInfo is still N-1
                                         download()
                                           flushIfNeeded(0)
                                             applyingTransactions > 0
                                             return
                                           checkpoint:
                                             index N-1 + data through N-1
                                             consistent

updateLatestTrxInfo(N)
endApplyingTransaction()

                                         next download()
                                           flushIfNeeded(0)
                                             commitBatchOperation()
                                           checkpoint:
                                             index N + data through N
                                             consistent

What is the link to the Apache JIRA?

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

How was this patch tested?

The regression test fails with the old flush() because data for index N is committed during transaction apply, and passes with this change.

CI: https://github.com/F64116045/ozone/actions/runs/40821330694

@github-actions github-actions Bot added the scm label Oct 29, 2026
@F64116045
F64116045 marked this pull request as ready for review October 29, 2026 06:35

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

lgtm trivial fix

@jojochuang

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/HDDS-16453 is the same issue that happens to StatefulServiceStateManagerImpl

@jojochuang

Copy link
Copy Markdown
Contributor

@F64116045

Copy link
Copy Markdown
Contributor Author

https://issues.apache.org/jira/browse/HDDS-16453 is the same issue that happens to StatefulServiceStateManagerImpl

Thanks for the heads-up! I'm working on HDDS-16453 too.

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.

2 participants