Skip to content
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

Improve topic logging and buffer overflow handling #204

Merged
merged 2 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,12 @@ public void handleCommitResponse(long committedOffset) {
return;
}
Map<Long, CompletableFuture<Void>> futuresToComplete = commitFutures.headMap(committedOffset, true);
logger.info("[{}] Commit response received for partition session {} (partition {}). Committed offset: {}" +
". Previous committed offset: {} (diff is {} message(s)). Completing {} commit futures",
path, id, partitionId, committedOffset, lastCommittedOffset, committedOffset - lastCommittedOffset,
futuresToComplete.size());
if (logger.isDebugEnabled()) {
logger.debug("[{}] Commit response received for partition session {} (partition {}). Committed offset: {}" +
". Previous committed offset: {} (diff is {} message(s)). Completing {} commit futures",
path, id, partitionId, committedOffset, lastCommittedOffset, committedOffset - lastCommittedOffset,
futuresToComplete.size());
}
lastCommittedOffset = committedOffset;
futuresToComplete.values().forEach(future -> future.complete(null));
futuresToComplete.clear();
Expand Down
17 changes: 9 additions & 8 deletions topic/src/main/java/tech/ydb/topic/write/impl/WriterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,22 @@ public CompletableFuture<Void> tryToEnqueue(EnqueuedMessage message, boolean ins
logger.info("[{}] Message queue in-flight limit of {} reached. Putting the message into incoming " +
"waiting queue", id, settings.getMaxSendBufferMessagesCount());
}
} else if (availableSizeBytes <= message.getMessage().getData().length) {
} else if (availableSizeBytes < message.getMessage().getData().length) {
if (instant) {
String errorMessage = "[" + id +
"] Rejecting a message due to reaching message queue size limit of " +
settings.getMaxSendBufferMemorySize() + " bytes. Buffer currently has " +
currentInFlightCount + " messages with " + availableSizeBytes +
String errorMessage = "[" + id + "] Rejecting a message of " +
message.getMessage().getData().length +
" bytes: not enough space in message queue. Buffer currently has " + currentInFlightCount +
" messages with " + availableSizeBytes + " / " + settings.getMaxSendBufferMemorySize() +
" bytes available";
logger.info(errorMessage);
CompletableFuture<Void> result = new CompletableFuture<>();
result.completeExceptionally(new QueueOverflowException(errorMessage));
return result;
} else {
logger.info("[{}] Message queue size limit of {} bytes reached. Putting the message into incoming" +
" waiting queue. Buffer currently has {} messages with {} bytes available", id,
settings.getMaxSendBufferMemorySize(), currentInFlightCount, availableSizeBytes);
logger.info("[{}] Can't accept a message of {} bytes into message queue. Buffer currently has " +
"{} messages with {} / {} bytes available. Putting the message into incoming " +
"waiting queue.", id, message.getMessage().getData().length, currentInFlightCount,
availableSizeBytes, settings.getMaxSendBufferMemorySize());
}
} else if (incomingQueue.isEmpty()) {
acceptMessageIntoSendingQueue(message);
Expand Down