Skip to content

PHOENIX-7977 Stage forwarded replication log files in a per-shard staging subdirectory before atomic rename - #2590

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

PHOENIX-7977 Stage forwarded replication log files in a per-shard staging subdirectory before atomic rename#2590
tkhurana wants to merge 1 commit into
apache:PHOENIX-7562-feature-newfrom
tkhurana:PHOENIX-7977

Conversation

@tkhurana

Copy link
Copy Markdown
Contributor

The forwarder copied a fallback-cluster log file straight onto its final _.plog name on the peer via FileUtil.copy (overwrite=false). Because FileUtil.copy publishes the file at that replay-eligible name before close() completes, the standby replay consumer could pick up the half-written file, force-recover the HDFS lease, and cause the forwarder's close() to fail with LeaseExpiredException. That threw out of processFile before the STORE_AND_FORWARD -> SYNC_AND_FORWARD throughput check, delaying the mode transition.

Fix: copy into a per-shard .staging subdirectory (/.staging/_.plog, overwrite=true to reclaim orphans) and atomically rename it up to the final .plog in the shard directory once fully written. The staged file keeps its real .plog name but is invisible to replay because every listing gates on FileStatus.isFile(), which skips the subdirectory and anything inside it. Replay only ever sees the atomically published file. Delivery remains at-least-once (unchanged); replay idempotency makes a re-publish safe.

Tests: forwarder staging/rename/retry/orphan cases in ReplicationLogDiscoveryForwarderTest; .staging-subdirectory exclusion across the listing entry points in ReplicationLogTrackerTest.

…ging subdirectory before atomic rename

The forwarder copied a fallback-cluster log file straight onto its final
<ts>_<origin>.plog name on the peer via FileUtil.copy (overwrite=false).
Because FileUtil.copy publishes the file at that replay-eligible name before
close() completes, the standby replay consumer could pick up the half-written
file, force-recover the HDFS lease, and cause the forwarder's close() to fail
with LeaseExpiredException. That threw out of processFile before the
STORE_AND_FORWARD -> SYNC_AND_FORWARD throughput check, delaying the mode
transition.

Fix: copy into a per-shard .staging subdirectory (<shard>/.staging/<ts>_<origin>.plog,
overwrite=true to reclaim orphans) and atomically rename it up to the final .plog
in the shard directory once fully written. The staged file keeps its real .plog
name but is invisible to replay because every listing gates on
FileStatus.isFile(), which skips the subdirectory and anything inside it. Replay
only ever sees the atomically published file. Delivery remains at-least-once
(unchanged); replay idempotency makes a re-publish safe.

Tests: forwarder staging/rename/retry/orphan cases in
ReplicationLogDiscoveryForwarderTest; .staging-subdirectory exclusion across the
listing entry points in ReplicationLogTrackerTest.
@tkhurana

Copy link
Copy Markdown
Contributor Author

@Himanshu-g81 can you take a look

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