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 cache refresh and add metrics #7

Merged
merged 5 commits into from
Jan 11, 2022
Merged

fix cache refresh and add metrics #7

merged 5 commits into from
Jan 11, 2022

Conversation

keepsimple1
Copy link
Owner

@keepsimple1 keepsimple1 commented Jan 10, 2022

  1. The main purpose is to fix a bug in "cache refresh": the daemon would repeatedly send out query packets to refresh its cache when a record refresh_due returns True before the record expires.

Because there is a "20% of TTL" time span between "refresh" and "expire", this can cause an outgoing packets surge due to cache refresh. The fix is: only refresh once for any refresh-due record.

  1. To debug this issue and to help similar debugging in the future, I also added a metrics (counters) for outgoing traffic. A user can easily pull the metrics by calling get_metrics of the daemon, and use recv() or try_recv().

  2. Fix a problem in retransmission: currently the retransmissions is a BTreeMap and there is a non-zero chance that two retransmissions are scheduled with the same next_time, hence the 2nd one will overwrite the first one in the BTreeMap due to the same key. The fix is to change the data structure to a Vec.

  3. Updated the integration test to cover the metrics.

@keepsimple1 keepsimple1 merged commit c5a759e into main Jan 11, 2022
@keepsimple1 keepsimple1 deleted the counters branch January 11, 2022 02:19
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.

1 participant