Skip to content

SyncWriter.flush() now throw Exception when previous task was failed #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions topic/src/main/java/tech/ydb/topic/write/impl/WriterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,19 @@ protected CompletableFuture<CompletableFuture<WriteAck>> sendImpl(Message messag
return tryToEnqueue(enqueuedMessage, instant).thenApply(v -> enqueuedMessage.getFuture());
}

/**
* Create a wrapper upon the future for the flush method.
*
* @return an empty Future if successful. Throw CompletionException when an error occurs.
*/
protected CompletableFuture<Void> flushImpl() {
if (this.lastAcceptedMessageFuture == null) {
return CompletableFuture.completedFuture(null);
}
incomingQueueLock.lock();

try {
return this.lastAcceptedMessageFuture.isDone()
? CompletableFuture.completedFuture(null)
: this.lastAcceptedMessageFuture.thenApply(v -> null);
return this.lastAcceptedMessageFuture.thenApply(v -> null);
} finally {
incomingQueueLock.unlock();
}
Expand Down