Skip to content

Commit 809e330

Browse files
authored
Merge pull request #1003: [beam-core] fix waiting in finishing bundle in ProximaIO.write
2 parents 5b85326 + d4f16db commit 809e330

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ public void finishBundle() {
124124
while (missingResponses.get() > 0) {
125125
long elapsed = System.currentTimeMillis() - startTime;
126126
if (elapsed >= bundleFinalizeTimeoutMs) {
127-
throw new IllegalStateException("Failed to flush bundle within timeout of 5s");
127+
throw new IllegalStateException(
128+
"Failed to flush bundle within timeout of " + bundleFinalizeTimeoutMs);
128129
}
129130
// clone to avoid ConcurrentModificationException
130131
final Collection<CompletableFuture<Pair<Boolean, Throwable>>> unfinished;
@@ -135,9 +136,12 @@ public void finishBundle() {
135136
Optional<Pair<Boolean, Throwable>> failedFuture =
136137
unfinished.stream()
137138
.map(
138-
f ->
139-
ExceptionUtils.uncheckedFactory(
140-
() -> f.get(bundleFinalizeTimeoutMs - elapsed, TimeUnit.MILLISECONDS)))
139+
f -> {
140+
long maxWaitMs =
141+
bundleFinalizeTimeoutMs - System.currentTimeMillis() + startTime;
142+
return ExceptionUtils.uncheckedFactory(
143+
() -> f.get(maxWaitMs, TimeUnit.MILLISECONDS));
144+
})
141145
.filter(p -> !p.getFirst())
142146
// this will be retried
143147
.filter(p -> !(p.getSecond() instanceof TransactionRejectedException))

direct/io-pubsub/module/src/main/java/cz/o2/proxima/direct/io/pubsub/AbstractPubSubWriter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public synchronized void close() {
142142
}
143143
executor.shutdown();
144144
executor.awaitTermination(10, TimeUnit.SECONDS);
145+
executor = null;
145146
publisher.shutdown();
146147
} catch (Exception ex) {
147148
log.warn("Failed to shutdown publisher {}", publisher, ex);

0 commit comments

Comments
 (0)