jt2594838 commented on code in PR #18453:
URL: https://github.com/apache/iotdb/pull/18453#discussion_r3764893304
##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/SyncStatus.java:
##########
@@ -49,10 +49,15 @@ public SyncStatus(IndexController controller,
IoTConsensusConfig config) {
* @throws InterruptedException
*/
public synchronized void addNextBatch(Batch batch) throws
InterruptedException {
- while ((pendingBatches.size() >=
config.getReplication().getMaxPendingBatchesNum()
- || !iotConsensusMemoryManager.reserve(batch))
- && !Thread.interrupted()) {
- wait();
+ while (true) {
+ while (pendingBatches.size() >=
config.getReplication().getMaxPendingBatchesNum()) {
+ wait();
+ }
+ if (iotConsensusMemoryManager.reserve(batch)) {
+ break;
+ }
+ // Memory may be freed by another SyncStatus, which cannot notify this
monitor.
+ wait(Math.max(1, config.getReplication().getBasicRetryWaitTimeMs()));
Review Comment:
A failed reservation cannot rely on this monitor being notified: memory may
be released by another `SyncStatus`, and the first batch has no local
completion callback. Retrying after the configured basic interval guarantees
progress while the separate queue-capacity loop still uses `removeBatch()`
notifications. Letting `wait` propagate `InterruptedException` also prevents an
interrupted dispatcher from enqueueing a batch whose memory was never reserved.
--
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]