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

[fix][broker] Fix reading entries failed due to max in-flight reading #23524

Closed
wants to merge 2 commits into from
Closed
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 @@ -23,6 +23,8 @@
import io.opentelemetry.api.metrics.ObservableLongCounter;
import io.prometheus.client.Gauge;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.opentelemetry.Constants;
Expand Down Expand Up @@ -56,7 +58,9 @@ public class InflightReadsLimiter implements AutoCloseable {
.help("Available space for inflight data read from storage or cache")
.register();

private final long maxReadsInFlightSize;
@Setter
@Getter
private long maxReadsInFlightSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable should stay final

private long remainingBytes;

public InflightReadsLimiter(long maxReadsInFlightSize, OpenTelemetry openTelemetry) {
Expand Down Expand Up @@ -178,5 +182,4 @@ public boolean isDisabled() {
return maxReadsInFlightSize <= 0;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ private AsyncCallbacks.ReadEntriesCallback handlePendingReadsLimits(ReadHandle l
}
long estimatedReadSize = (1 + lastEntry - firstEntry)
* (estimatedEntrySize + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
final long maxReadsInFlightSize = pendingReadsLimiter.getMaxReadsInFlightSize();
if (estimatedReadSize > maxReadsInFlightSize) {
String message = "Estimated read size " + estimatedReadSize
+ " is larger than managedLedgerMaxReadsInFlightSize " + maxReadsInFlightSize
+ " please check managedLedgerMaxReadsInFlightSizeInMB";
log.warn(message);
pendingReadsLimiter.setMaxReadsInFlightSize(estimatedReadSize);
Technoboy- marked this conversation as resolved.
Show resolved Hide resolved
}
final AsyncCallbacks.ReadEntriesCallback callback;
InflightReadsLimiter.Handle newHandle = pendingReadsLimiter.acquire(estimatedReadSize, handle);
if (!newHandle.success) {
Expand Down
Loading