Repository navigation
HBASE-30433 Seed the master's flushedSequenceIdByRegion watermark with the region's final flushed seqid on region CLOSE - #8707
Conversation
8e63fcf to
7b5b6a7
Compare
…h the region's final flushed seqid on region CLOSE On graceful region CLOSE the RegionServer now reports the region's durable flushed seqid (HRegion.getMaxFlushedSeqId()) on the CLOSED transition, and the master lifts its flushedSequenceIdByRegion watermark from it via the existing monotonic reportRegionOpen(merge(Math::max)) seed. This narrows the graceful-close window where a subsequent WAL split of a crashed source RS could otherwise treat already-durable edits as unflushed and write orphaned recovered.edits. No proto/RPC change: the RegionStateTransition message already carries an optional openSeqNum field and the CLOSED transition is already routed through the same master-side handler. HRegionServer now also sets that field for CLOSED (not just OPENED), and AssignmentManager seeds the watermark on CLOSED when seqId >= 0. Adds TestGetLastFlushedSequenceId#testFlushedSequenceIdSeededOnRegionClose.
7b5b6a7 to
dc643a2
Compare
virajjasani
left a comment
There was a problem hiding this comment.
Left few comments, +1 otherwise
| // write orphaned recovered.edits for already-durable edits. Uses the same monotonic | ||
| // merge(Math::max) seed, so it never regresses a higher value. | ||
| if (transition.getTransitionCode() == TransitionCode.CLOSED && seqId >= 0) { | ||
| master.getServerManager().reportRegionOpen(hri, seqId); |
There was a problem hiding this comment.
Since now region OPEN, FAILED_OPEN and CLOSED cases use the same ServerManager API, instead of calling it reportRegionOpen(), we can rename it to something generic like advanceRegionFlushedSeq().
There was a problem hiding this comment.
Since now region OPEN, FAILED_OPEN and CLOSED cases use the same ServerManager API, instead of calling it
reportRegionOpen(), we can rename it to something generic likeadvanceRegionFlushedSeq().
Renamed the API to advanceRegionFlushedSeq(). JFYI FAILED_OPEN region state doesn't move the watermark forward, since a failed open has nothing new made durable to report.
| assertTrue(ids.getLastFlushedSequenceId() >= flushedSeqId, | ||
| "CLOSE seed " + ids.getLastFlushedSequenceId() + " must be >= the region's flushed seqid " | ||
| + flushedSeqId); |
There was a problem hiding this comment.
After retrieving flushedSeqId, since we are only disabling the table, is it possible for ids.getLastFlushedSequenceId() to be greater than flushedSeqId? Or they both should be same?
There was a problem hiding this comment.
Yes, they should be equal. A close only flushes when there's data in the memstore, and the heartbeat reports the same maxFlushedSeqId, so nothing can push the value above it. I've changed the unit test also to leave edits unflushed, so the close's own flush moves the seqid forward. It now uses assertEquals, and it fails without the fix
…n close-seed test - Rename ServerManager#reportRegionOpen to advanceRegionFlushedSeq since it is now called on both region OPEN and CLOSE; generalize its javadoc. - testFlushedSequenceIdSeededOnRegionClose now leaves edits unflushed so the close flush itself advances maxFlushedSeqId (a pre-close heartbeat cannot carry that value), and asserts the master's watermark equals it. The old version passed even with the CLOSE seed disabled because 1s heartbeats delivered the same value.
|
Awaiting workflow results |
…h the region's final flushed seqid on region CLOSE (#8707) Signed-off-by: Viraj Jasani <vjasani@apache.org>
…h the region's final flushed seqid on region CLOSE (#8707) Signed-off-by: Viraj Jasani <vjasani@apache.org>
JIRA: https://issues.apache.org/jira/browse/HBASE-30433
Summary
Seed the master's
flushedSequenceIdByRegionwatermark with the region's final flushed seqid on region CLOSE, so a subsequent WAL split of a drained/crashed source RS recognizes already-durable edits instead of writing orphanedrecovered.edits.Why
The master already seeds this watermark with
openSeqNumat region OPEN. That is the correct primary fence and fires on every reopen path, but it leaves one narrow graceful-close window uncovered:OPEN, so the OPEN-time seed has not fired.flushedSequenceIdByRegion, and writes a (harmless-but-present)recovered.editsfile.Seeding on CLOSE advances the watermark to the region's reported flushed seqid before the source RS dies, closing this sub-window for the graceful-close case. This is additive: it does nothing for the pure-crash / never-gracefully-closed path (there is no close report), so the OPEN-time seed remains. Both writers go through the same monotonic
merge(Math::max), so they compose safely and never regress a higher value.Change
No protobuf/RPC change — the
RegionStateTransitionmessage already carries an optionalopenSeqNumfield and theCLOSEDtransition is already routed through the same master-side handler.CloseRegionHandlerandUnassignRegionHandlerreportHRegion.getMaxFlushedSeqId()on theCLOSEDtransition (wasHConstants.NO_SEQNUM).HRegionServer.createReportRegionStateTransitionRequestnow sets the wireopenSeqNumfield forCLOSEDtoo (when>= 0), not justOPENED.AssignmentManagerseeds the watermark on theCLOSEDtransition viaserverManager.advanceRegionFlushedSeq(regionInfo, seqId)whenseqId >= 0(the existing atomic max-merge).ServerManager#reportRegionOpen→advanceRegionFlushedSeq, since it now serves both OPEN and CLOSE; javadoc generalized. Callers andTestServerManagerupdated.Test
Adds
TestGetLastFlushedSequenceId#testFlushedSequenceIdSeededOnRegionClose: write rows without flushing, thendisableTable(a graceful close that keeps the region — unlike delete/split/merge, disable does not callServerManager#removeRegion). The close's own flush advancesmaxFlushedSeqId, and a heartbeat sent before the close cannot carry that value. The test asserts the master's watermark equals the post-close flushed seqid. Verified that it fails with the CLOSE seed disabled (expected: <7> but was: <2>). An earlier version flushed before the close and passed even without the fix, because the 1s heartbeats delivered the same value.Local run on current master (JDK17):
TestGetLastFlushedSequenceId3/3,TestServerManager5/5,TestMergeTableRegionsProcedure9/9,TestAssignmentManagerUtil3/3,TestMaster7/7,TestDLSFSHLog3/3,TestDLSAsyncFSWAL3/3 green;spotless:checkonhbase-serverclean.Note on stacking
Builds on #8584 (HBASE-30335, now merged to master), which introduced the OPEN-time seed (
ServerManager.reportRegionOpen, renamed here toadvanceRegionFlushedSeq) that this reuses. Rebased onto master: the first commit is the CLOSE-time seed, and the second addresses review feedback.branch-2 backport: #8760.