void-ptr974 opened a new pull request, #26005: URL: https://github.com/apache/pulsar/pull/26005
### Motivation `PersistentReplicator.readMoreEntries()` created an `InFlightTask` before checking the replicator dispatch rate limiter. When replicator dispatch throttling was enabled and the rate limiter had no message or byte permits, the method scheduled a retry and returned without issuing `cursor.asyncReadEntriesOrWait(...)`. The newly-created task stayed in `entries == null`, so it looked like a pending cursor read even though no read request existed. On the next retry, `hasPendingRead()` returned true and the replicator stopped scheduling further reads. This could leave geo-replication stuck with backlog when replicator dispatch throttling is enabled. ### Modifications Compute producer and rate-limiter permits before creating the in-flight read task. Create the `InFlightTask` only after confirming that a real cursor read will be issued. This preserves the invariant that an `entries == null` in-flight task corresponds to an actual pending cursor read. Added a unit test covering the no-permit rate-limiter path for both message and byte throttling, verifying that no pending in-flight read task is created. ### Verifying this change This change added tests and can be verified as follows: - `./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.service.persistent.PersistentReplicatorInflightTaskTest.testRateLimiterWithoutPermitsDoesNotCreateInFlightTask` - `./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.service.persistent.PersistentReplicatorInflightTaskTest.testAcquirePermitsIfNotFetchingSchema` - `./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.service.ReplicatorRateLimiterTest.testReplicatorRateLimiterMessageReceivedAllMessages` - `./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.service.ReplicatorRateLimiterTest.testReplicatorRateLimiterByBytes` ### Does this pull request potentially affect one of the following parts: - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The schema - [ ] The default values of configurations - [ ] The threading model - [ ] The binary protocol - [ ] The REST endpoints - [ ] The admin CLI options - [ ] The metrics - [ ] Anything that affects deployment -- 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]
