Skip to content

PHOENIX-7931 Coalesce per-batch mutations into a single record#2540

Open
tkhurana wants to merge 1 commit into
apache:PHOENIX-7562-feature-newfrom
tkhurana:PHOENIX-7562-feature-new
Open

PHOENIX-7931 Coalesce per-batch mutations into a single record#2540
tkhurana wants to merge 1 commit into
apache:PHOENIX-7562-feature-newfrom
tkhurana:PHOENIX-7562-feature-new

Conversation

@tkhurana

Copy link
Copy Markdown
Contributor

PHOENIX-7931: Coalesce per-batch replication appends into a single record

Targets the PHOENIX-7562-feature-new feature branch (not master).

What changed

On the write path, a server-side batch's mutations for a given table are now coalesced into a single replication log record carrying a flat cell stream, rather than one record per mutation. On the replay path, MutationCellGrouper reconstructs Put/Delete mutations from that cell stream on the row + put-vs-delete boundary, mirroring the algorithm HBase's ReplicationSink uses for WALEdits.

This cuts ring-buffer pressure substantially (≈5× fewer Disruptor events at high batch sizes) without changing the fsync floor — coalescing already minimized inner syncs. The on-disk record format changes accordingly (per-cell row/family/qualifier/timestamp/type/value, with a per-record table name + commitId + attributes header).

Key files

  • IndexRegionObserver — per-(table, batch) cell aggregation before a single append
  • MutationCellGrouper (new) — replay-side cell-stream → mutation regrouping
  • LogFileCodec / LogFileRecord / LogFile — new coalesced record format
  • ReplicationLogGroup / ReplicationLog — cell-oriented append API

Testing

  • New MutationCellGrouperTest (10 cases): empty input, single Put/Delete, contiguous same-row/type coalescing, row-change splits, Put→Delete same-row type-boundary split, three-row Put/Delete/Put, adjacent DeleteColumn/DeleteFamily subtype split, non-consecutive same-row partitioning, and cell preservation.
  • New testAppendAndSyncSingleBatchRecordCount IT pins the coalesced record-count contract with cross-cluster cell-level equality.
  • New testSyncMetricsEmitted unit test — deterministic replacement for the flaky IT metrics assertion (injects an fsync delay to clear ms-truncation; reads metrics only after a graceful close that joins the consumer).
  • Expanded LogFileCodecTest round-trip coverage for the new format (multi-family ordering, empty-record rejection, all cell types).
  • testReplicationSyncPathSimulator (opt-in) for sync-coalescing measurement under contention.

Verification

  • phoenix-core-server compiles clean; MutationCellGrouperTest, LogFileCodecTest, and the replication unit tests pass.
  • mvn spotless:check passes on both phoenix-core-server and phoenix-core.

Switch the replication log framing to a cell-oriented record (List<Cell> +
record-level attributes) and coalesce IndexRegionObserver.replicateMutations
to emit one record per (data table, batch) and one record per index target
table per batch, instead of one record per Mutation. The consumer
reconstructs Put/Delete mutations on the row+type boundary via
MutationCellGrouper, so coprocessor-merged cells (local index, conditional
TTL, ON DUPLICATE KEY UPDATE) survive the framing change.

Drops the Mutation overload from LogFile.Writer (production no longer
needs it) and rewrites the test layer to assert against cell lists.
@tkhurana tkhurana requested a review from apurtell June 22, 2026 20:51
@tkhurana tkhurana changed the title PHOENIX-7931 Coalesce per-batch replication appends into a single record PHOENIX-7931 Coalesce per-batch mutations into a single record Jun 22, 2026
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