Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

uses current local timestamp when recording purged values #16573

Merged
merged 1 commit into from
Apr 20, 2021

Conversation

behzadnouri
Copy link
Contributor

@behzadnouri behzadnouri commented Apr 15, 2021

Problem

CrdsGossipPull.purged_values is meant to record recently purged values
so that they are excluded from imminent pull requests, until the entire
cluster have synced to the updated value:
https://github.com/solana-labs/solana/blob/c826cddbb/core/src/crds_gossip_pull.rs#L449-L454

However, VersionedCrdsValue.local_timestamp represents the local time
when the value was last updated, and given that crds values may have
different timeouts based on stake, it does not necessarily represent how
recently the value was purged:
https://github.com/solana-labs/solana/blob/c826cddbb/core/src/crds.rs#L75-L76

As such, recording current local timestamp when purging values is more
appropriate. Additionally, purge_purged assumes that the purge_values is
sorted in timestamps when draining the old ones; which is not true if
those timestamps are VersionedCrdsValue.local_timestamp:
https://github.com/solana-labs/solana/blob/c826cddbb/core/src/crds_gossip_pull.rs#L563-L571

Summary of Changes

  • use current local timestamp when recording purged values.

CrdsGossipPull.purged_values is meant to record recently purged values
so that they are excluded from imminent pull requests, until the entire
cluster have synced to the updated value:
https://github.com/solana-labs/solana/blob/c826cddbb/core/src/crds_gossip_pull.rs#L449-L454

However, VersionedCrdsValue.local_timestamp represents the local time
when the value was last updated, and given that crds values may have
different timeouts based on stake, it does not necessarily represent how
recently the value was purged:
https://github.com/solana-labs/solana/blob/c826cddbb/core/src/crds.rs#L75-L76

As such, recording current local timestamp when purging values is more
appropriate. Additionally, purge_purged assumes that the purge_values is
sorted in timestamps when draining the old ones; which is not true if
those timestamps are VersionedCrdsValue.local_timestamp:
https://github.com/solana-labs/solana/blob/c826cddbb/core/src/crds_gossip_pull.rs#L563-L571
@behzadnouri behzadnouri force-pushed the purged-values-timestamp branch from a213355 to 868394f Compare April 15, 2021 13:47
@behzadnouri behzadnouri requested a review from sakridge April 15, 2021 13:51
@codecov
Copy link

codecov bot commented Apr 15, 2021

Codecov Report

Merging #16573 (868394f) into master (9dfe545) will decrease coverage by 0.0%.
The diff coverage is 66.6%.

@@            Coverage Diff            @@
##           master   #16573     +/-   ##
=========================================
- Coverage    80.0%    80.0%   -0.1%     
=========================================
  Files         413      413             
  Lines      112153   112150      -3     
=========================================
- Hits        89788    89774     -14     
- Misses      22365    22376     +11     

@behzadnouri behzadnouri requested review from carllin and utsl42 April 16, 2021 18:29
@carllin
Copy link
Contributor

carllin commented Apr 20, 2021

Good catches!

So to summarize for my understanding.

The issue is the timestamps stored for the "purged" values in the purged set are currently based on the local_timestamp, i.e. when those values were last updated in gossip. Because we keep around values from staked validators for an extended period of time, this means it could have been a long time since that value was updated.

The importance of this is that "purged" values timestamps are also used for purging the purged set in purge_purged(). Thus if the timestamps used for expiring those values from the purge set are old, then we'll immediately remove those values from the purged set. This opens us up to getting redundant entries again via pull requests shortly after.

@behzadnouri
Copy link
Contributor Author

Good catches!

So to summarize for my understanding.

The issue is the timestamps stored for the "purged" values in the purged set are currently based on the local_timestamp, i.e. when those values were last updated in gossip. Because we keep around values from staked validators for an extended period of time, this means it could have been a long time since that value was updated.

The importance of this is that "purged" values timestamps are also used for purging the purged set in purge_purged(). Thus if the timestamps used for expiring those values from the purge set are old, then we'll immediately remove those values from the purged set. This opens us up to getting redundant entries again via pull requests shortly after.

yes, that is basically it

@behzadnouri behzadnouri merged commit bc90e04 into solana-labs:master Apr 20, 2021
@behzadnouri behzadnouri deleted the purged-values-timestamp branch April 20, 2021 11:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants