Skip to content

[cleanup] [broker] when serverCnx disabled auto read use same implements#15181

Merged
Jason918 merged 1 commit intoapache:masterfrom
poorbarcode:cleanup/ServerCnx#disableCnxAutoRead
Jun 21, 2022
Merged

[cleanup] [broker] when serverCnx disabled auto read use same implements#15181
Jason918 merged 1 commit intoapache:masterfrom
poorbarcode:cleanup/ServerCnx#disableCnxAutoRead

Conversation

@poorbarcode
Copy link
Contributor

@poorbarcode poorbarcode commented Apr 15, 2022

Motivation

if (++pendingSendRequest == maxPendingSendRequests || isPublishRateExceeded) {
// When the quota of pending send requests is reached, stop reading from socket to cause backpressure on
// client connection, possibly shared between multiple producers
ctx.channel().config().setAutoRead(false);
recordRateLimitMetrics(producers);
autoReadDisabledRateLimiting = isPublishRateExceeded;
throttledConnections.inc();
}

L2468-L2469 make serverCnx disabled auto read, but there has a beter implements at L2723-L2728:

public void disableCnxAutoRead() {
if (ctx != null && ctx.channel().config().isAutoRead()) {
ctx.channel().config().setAutoRead(false);
recordRateLimitMetrics(producers);
}
}

At the better implements, can reduce false statistics( when a serverCnx already disabled auto read, will not increment another once).

Documentation

  • doc-required
  • no-need-doc
  • doc
  • doc-added
  • doc-not-needed

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 15, 2022
@gaozhangmin gaozhangmin requested review from 315157973, eolivelli and michaeljmarshall and removed request for eolivelli and michaeljmarshall April 15, 2022 08:18
Copy link
Contributor

@gaozhangmin gaozhangmin left a comment

Choose a reason for hiding this comment

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

LGTM

@gaozhangmin gaozhangmin added this to the 2.11.0 milestone Apr 15, 2022
@poorbarcode
Copy link
Contributor Author

@michaeljmarshall could you take a look

@michaeljmarshall
Copy link
Member

Sorry @315157973, accidentally re-requested your review.

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

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

@poorbarcode thanks for your contribution. I had a couple questions about your findings, but overall, the PR looks good to me.

Note that this might be a minor performance optimization for connections with many producers. However, it's probably minimal because once a connection has auto-read disabled, this code would only ever complete the current execution of this method and wouldn't call it again.

// When the quota of pending send requests is reached, stop reading from socket to cause backpressure on
// client connection, possibly shared between multiple producers
ctx.channel().config().setAutoRead(false);
recordRateLimitMetrics(producers);
Copy link
Member

Choose a reason for hiding this comment

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

At the better implements, can reduce false statistics( when a serverCnx already disabled auto read, will not increment another once).

Is there evidence that this metric was getting incremented unnecessarily or is this just an inferred conclusion? Is the issue you're trying to prevent that the producer could have auto-read set to false concurrently? Calling the isAutoRead method as a guard does not prevent the race condition, though it might decrease its probability, because we read from the volatile variable and then update it. The consequence of the race is pretty low since the rate limit metrics are just prometheus metrics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this just an inferred conclusion ?

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this just an inferred conclusion?

yes

@poorbarcode
Copy link
Contributor Author

@lhotari Could you help me, I do not know what to do.

image

@poorbarcode
Copy link
Contributor Author

/pulsarbot run-failure-checks

@poorbarcode poorbarcode force-pushed the cleanup/ServerCnx#disableCnxAutoRead branch from 0ab7959 to a4e3f9b Compare May 17, 2022 13:36
@poorbarcode
Copy link
Contributor Author

@gaoran10 Could you take a look

@poorbarcode poorbarcode reopened this May 19, 2022
@poorbarcode
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

@poorbarcode Please rebase to the master branch.

@poorbarcode poorbarcode force-pushed the cleanup/ServerCnx#disableCnxAutoRead branch from a4e3f9b to eb0070a Compare June 12, 2022 11:37
@poorbarcode
Copy link
Contributor Author

@poorbarcode Please rebase to the master branch.

ok

@poorbarcode
Copy link
Contributor Author

@gaoran10 Can this PR merge ^_^?

@Jason918 Jason918 added area/broker type/cleanup Code or doc cleanups e.g. remove the outdated documentation or remove the code no longer in use labels Jun 21, 2022
@Jason918 Jason918 merged commit 5d563ac into apache:master Jun 21, 2022
@poorbarcode poorbarcode deleted the cleanup/ServerCnx#disableCnxAutoRead branch June 21, 2022 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/broker doc-not-needed Your PR changes do not impact docs type/cleanup Code or doc cleanups e.g. remove the outdated documentation or remove the code no longer in use

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

Comments