Skip to content

Commit b059799

Browse files
committed
[proxima-beam-core] refactor inflight writes locking
1 parent e165fbd commit b059799

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

beam/core/src/main/java/cz/o2/proxima/beam/io/ProximaIO.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ public void processElement(@Element StreamElement element) {
177177
boolean isTransactional =
178178
element.getAttributeDescriptor().getTransactionMode() != TransactionMode.NONE;
179179
int weight = isTransactional ? transactionalWriteWeight : 1;
180-
synchronized (pendingWrites) {
181-
while (inflightWriteWeights.get() >= maxPendingWrites) {
180+
while (inflightWriteWeights.get() + weight >= maxPendingWrites) {
181+
synchronized (pendingWrites) {
182182
ExceptionUtils.unchecked(() -> pendingWrites.wait(100));
183183
}
184-
inflightWriteWeights.addAndGet(weight);
185184
}
185+
inflightWriteWeights.addAndGet(weight);
186186
writeRunnableRef.set(
187187
() -> {
188188
CompletableFuture<Pair<Boolean, Throwable>> writeResult = new CompletableFuture<>();

0 commit comments

Comments
 (0)