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 for Issue 4014: simplified ping handling / deferral based on rece… #4015

Conversation

sandykellagher
Copy link
Contributor

Fix for issue #4014: using simplified ping handling / deferral based on receiving message or ping from the remote end
This is my own original work that I license to the project

  • [ x] Link to issue, e.g. Resolves #NNN
  • Documentation added (if applicable)
  • Tests added
  • [ x] Branch rebased on top of current main (git pull --rebase origin main)
  • [ x] Changes squashed to a single commit (described here)
  • Build is green in Travis CI
  • [ x] You have certified that the contribution is your original work and that you license the work to the project under the Apache 2 license

Resolves #

Changes proposed in this pull request:

  • add a lastRxMsg to the pinfo structure, and rename last to lastRxPing
  • update lastRxMsg in main read loop when any data message or subscription has been received
  • in pingTimer, hold off sending a ping based on lastRxMsg and lastRxPing values, and remove special coding for different types of connection

@sandykellagher sandykellagher requested a review from a team as a code owner April 3, 2023 12:01
@sandykellagher
Copy link
Contributor Author

I see this change resulted in a couple of JetStream cluster or supercluster tests failing. But it's not clear to me why that should be...

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

In general looks good, a few minor comments. Thanks!

last time.Time
out int
tmr *time.Timer
lastRxPing time.Time
Copy link
Member

Choose a reason for hiding this comment

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

Can these not be combined? I think they are doing the same which is recording inbound activity only.

pingInterval := c.srv.getOpts().PingInterval
if c.kind == GATEWAY {
pingInterval = adjustPingIntervalForGateway(pingInterval)
}
now := time.Now()
needRTT := c.rtt == 0 || now.Sub(c.rttStart) > DEFAULT_RTT_MEASUREMENT_INTERVAL

// Do not delay PINGs for GATEWAY or spoke LEAF connections.
if c.kind == GATEWAY || c.isSpokeLeafNode() {
Copy link
Member

Choose a reason for hiding this comment

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

Doing the write is most important over potential long haul or multi-hope networks. So even if we have received something we may need to write, so prefer this logic remains.

@sandykellagher
Copy link
Contributor Author

Closing this PR in favour of #4016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants