-
Notifications
You must be signed in to change notification settings - Fork 488
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
Events based cache: Address missed code review comments #5249
Conversation
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
// If there is a gap in the event stream, log the missed events for later processing. | ||
// For example if the current event ID is 6 and the previous one was 3, events 4 and 5 | ||
// were skipped over and need to be queued in case they show up later. | ||
// This can happen when a long running transaction allocates an event ID but a shorter transaction | ||
// comes in after, allocates and commits the ID first. If a read comes in at this moment, the event id for | ||
// the longer running transaction will be skipped over | ||
if a.receivedFirstRegistrationEntryEvent && event.EventID != a.lastRegistrationEntryEventID+1 { | ||
for i := a.lastRegistrationEntryEventID + 1; i < event.EventID; i++ { | ||
a.log.WithField(telemetry.EventID, i).Info("Detected skipped registration entry event") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addresses this comment: #5071 (comment)
// If there is a gap in the event stream, log the missed events for later processing | ||
// If there is a gap in the event stream, log the missed events for later processing. | ||
// For example if the current event ID is 6 and the previous one was 3, events 4 and 5 | ||
// were skipped over and need to be queued in case they show up later. | ||
// This can happen when a long running transaction allocates an event ID but a shorter transaction | ||
// comes in after, allocates and commits the ID first. If a read comes in at this moment, the event id for | ||
// the longer running transaction will be skipped over | ||
if a.receivedFirstAttestedNodeEvent && event.EventID != a.lastRegistrationEntryEventID+1 { | ||
for i := a.lastAttestedNodeEventID + 1; i < event.EventID; i++ { | ||
a.log.WithField(telemetry.EventID, i).Info("Detected skipped attested node event") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addresses this comment: #5071 (comment)
if commonEntry == nil { | ||
a.cache.RemoveEntry(entryID) | ||
return nil | ||
} | ||
|
||
entry, err := api.RegistrationEntryToProto(commonEntry) | ||
if err != nil { | ||
a.cache.RemoveEntry(entryID) | ||
return nil | ||
return fmt.Errorf("removing malformed entry %s from cache: %w", entryID, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addresses this comment: #5071 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't returning an error here result in the event being processed again (and again and again), presumably with the same outcome each time (assuming the entry is malformed)?
IMO, this condition should be logged but otherwise the event should be considered handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed.
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
entry, err := api.RegistrationEntryToProto(commonEntry) | ||
if err != nil { | ||
a.cache.RemoveEntry(entryID) | ||
a.log.WithField(telemetry.RegistrationID, entryID).Info("Removed malformed registration entry from cache") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is problematic enough we should log it at Warn level
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
Signed-off-by: Faisal Memon <fymemon@yahoo.com>
Pull Request check list
Affected functionality
Events based cache
Description of change
Addressing some comments missed in review of #5071. It was merged before i could address them.
Which issue this PR fixes