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: update MessageDispatcher to not extend deadlines of messages which arrive early to 60s #570

Merged
merged 3 commits into from Mar 16, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -82,9 +82,10 @@ class MessageDispatcher {
private final LinkedBlockingQueue<String> pendingNacks = new LinkedBlockingQueue<>();
private final LinkedBlockingQueue<String> pendingReceipts = new LinkedBlockingQueue<>();

// The deadline should be set before use. Here, set it to something unreasonable,
// so we fail loudly if we mess up.
private final AtomicInteger messageDeadlineSeconds = new AtomicInteger(60);
// Start the deadline at the minimum ack deadline so messages which arrive before this is
// updated will not have a long ack deadline.
private final AtomicInteger messageDeadlineSeconds =
new AtomicInteger(Subscriber.MIN_ACK_DEADLINE_SECONDS);
private final AtomicBoolean extendDeadline = new AtomicBoolean(true);
private final Lock jobLock;
private ScheduledFuture<?> backgroundJob;
Expand Down
Expand Up @@ -184,9 +184,9 @@ public Void apply(UnaryCallSettings.Builder<?, ?> settingsBuilder) {
streamingSubscriberConnections = new ArrayList<StreamingSubscriberConnection>(numPullers);

// We regularly look up the distribution for a good subscription deadline.
// So we seed the distribution with something reasonable to start with.
// So we seed the distribution with the minimum value to start with.
// Distribution is percentile-based, so this value will eventually lose importance.
ackLatencyDistribution.record(60);
ackLatencyDistribution.record(MIN_ACK_DEADLINE_SECONDS);
}

/**
Expand Down