tkhurana opened a new pull request, #2487: URL: https://github.com/apache/phoenix/pull/2487
## Summary When the replication log producer is idle, a scheduled rotation tick stages a new writer in `pendingWriter` but the disruptor consumer never reaches `checkAndReplaceWriter()` since that runs only as a side-effect of processing `DATA`/`SYNC` events. The reader's round-buffer interval (9s default) can then expire and trigger HDFS lease recovery on the still-open old writer — observed gap on a test cluster: 44s between the rotation tick and the writer close. This change adds a synthetic `EVENT_TYPE_SWAP` marker on the disruptor ring buffer: - `ReplicationLogGroup.publishSwapEvent()` publishes the marker via `RingBuffer#tryNext()` — non-blocking; silently skipped on `InsufficientCapacityException` since a full buffer means the consumer is already draining. - `LogRotationTask.run()` calls `publishSwapEvent()` after staging a new pending writer. - `LogEventHandler.onEvent()` handles `EVENT_TYPE_SWAP` by invoking `checkAndReplaceWriter(true)`. The `endOfBatch → processPendingSyncs()` call is unified across all event types so a `SWAP` arriving as the last event in a batch does not strand pending sync futures. This is a fire-and-forget wake-up — no safe-point handshake — because no ordering invariant requires the swap to occur at a precise boundary. Also includes a small test-hygiene fix: two existing tests had a Mockito stubbing race where `doThrow(...).when(spy).method(...)` ran concurrently with consumer-thread invocations on the same spy, surfacing as a misleading `MockitoException: Checked exception is invalid for this method!` under sustained iteration. Stubs are now hoisted ahead of the first `logGroup.append/sync` in `testInFlightAppendsReplayAfterModeSwitch` and `testRetryPicksUpStagedWriter`. The now-inaccurate `@VisibleForTesting` on `ReplicationModeImpl#getReplicationLog` is dropped since it is invoked from the swap-event handler. ## Test plan - [x] `mvn test -pl phoenix-core -Dtest=ReplicationLogGroupTest` — 47 tests pass - [x] `mvn test -pl phoenix-core -Dtest=ReplicationLogTest` — 2 tests pass - [x] `mvn spotless:apply` clean - [x] New `testIdleConsumerSwapsOnRotation` — verifies swap completes without further events - [x] New `testPublishSwapEventOnFullRingBufferIsNoop` — verifies non-blocking publish on full buffer -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
