Visitar URL original
HBASE-30433 Seed the master's flushedSequenceIdByRegion watermark with the region's final flushed seqid on region CLOSE by nirdosh0110 · Pull Request #8707 · apache/hbase · GitHub
Skip to content

HBASE-30433 Seed the master's flushedSequenceIdByRegion watermark with the region's final flushed seqid on region CLOSE - #8707

Open
nirdosh0110 wants to merge 1 commit into
apache:masterfrom
nirdosh0110:HBASE-30433
Open

nirdosh0110 wants to merge 1 commit into
apache:masterfrom
nirdosh0110:HBASE-30433

Conversation

@nirdosh0110

@nirdosh0110 nirdosh0110 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

JIRA: https://issues.apache.org/jira/browse/HBASE-30433

Summary

Seed the master's flushedSequenceIdByRegion watermark 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 orphaned recovered.edits.

Why

The master already seeds this watermark with openSeqNum at region OPEN. That is the correct primary fence and fires on every reopen path, but it leaves one narrow graceful-close window uncovered:

  1. A region is gracefully closed on the source RS (memstore flushed to the close marker).
  2. The source RS dies before the target RS finishes OPEN, so the OPEN-time seed has not fired.
  3. The source RS's SCP splits its WAL in that window, filtering against a still-stale flushedSequenceIdByRegion, and writes a (harmless-but-present) recovered.edits file.

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 RegionStateTransition message already carries an optional openSeqNum field and the CLOSED transition is already routed through the same master-side handler.

  • RegionServer — CloseRegionHandler and UnassignRegionHandler report HRegion.getMaxFlushedSeqId() on the CLOSED transition (was HConstants.NO_SEQNUM). HRegionServer.createReportRegionStateTransitionRequest now sets the wire openSeqNum field for CLOSED too (when >= 0), not just OPENED.
  • Master — AssignmentManager seeds the watermark on the CLOSED transition via serverManager.reportRegionOpen(regionInfo, seqId) when seqId >= 0 (the existing atomic max-merge).

Test

Adds TestGetLastFlushedSequenceId#testFlushedSequenceIdSeededOnRegionClose: write + flush past openSeqNum, disableTable (a graceful close that keeps the region — unlike delete/split/merge, disable does not call ServerManager#removeRegion), then assert the watermark reflects the post-close flushed seqid.

Local run on current master (JDK17): TestGetLastFlushedSequenceId 3/3, TestServerManager 5/5, TestMergeTableRegionsProcedure 9/9, TestAssignmentManagerUtil 3/3, TestMaster 7/7, TestDLSFSHLog 3/3, TestDLSAsyncFSWAL 3/3 green; spotless:check on hbase-server clean.

Note on stacking

Builds on #8584 (HBASE-30335, now merged to master), which introduced the ServerManager.reportRegionOpen seed this reuses. Rebased onto master; this PR is now the single CLOSE-time commit.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant