-
Notifications
You must be signed in to change notification settings - Fork 616
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: avoid duplicated batch updates #1029
fix: avoid duplicated batch updates #1029
Conversation
…cated-batches-update
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## fix-bridge-history-api-write-db #1029 +/- ##
==================================================================
Coverage ? 56.27%
==================================================================
Files ? 88
Lines ? 9000
Branches ? 0
==================================================================
Hits ? 5065
Misses ? 3516
Partials ? 419
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
// Perform a final check to confirm the existence of the key to ensure consistency between ZCard and ZRange data reads. | ||
exists, err := h.redis.Exists(ctx, cacheKey).Result() | ||
if err != nil { | ||
log.Error("failed to check if key exists", "error", err) | ||
return nil, 0, false, err | ||
} | ||
|
||
// If the key does not exist, we consider it a cache miss and return accordingly. | ||
if exists == 0 { | ||
return nil, 0, false, nil | ||
} |
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.
I think this is no necessary
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.
it's necessary because if the key does not exist, it will return nil value, and cannot differentiate:
- cache key exists but the value is nil.
- cache key does not exist.
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.
i think just check total or value whether empty
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.
Yeah. but if the txs under the address are empty, it would be treated as "key not found", too.
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.
changed in 1d325cb
Purpose or design rationale of this PR
Currently, the batch index information is not updated repeatedly within the buffer until the arrival of the next message. In situations where messages are sparse, this could significantly reduce the speed of the L1 fetcher.
An example (in block 4259 to block 4345 there is no message):
PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
Deployment tag versioning
Has
tag
incommon/version.go
been updated or have you addedbump-version
label to this PR?Breaking change label
Does this PR have the
breaking-change
label?