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

db: add AtomicContext #4724

Merged
merged 4 commits into from
Nov 2, 2022

Conversation

algorandskiy
Copy link
Contributor

Summary

Atomic() doesn't accept a context, but always passes context.Background() to the callback fn.

This PR adds AtomicContext() that does accept a context and passes it to its callback.

Replaces #4104

@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Merging #4724 (5bc707a) into master (a8f1b4a) will decrease coverage by 0.64%.
The diff coverage is 80.00%.

@@            Coverage Diff             @@
##           master    #4724      +/-   ##
==========================================
- Coverage   54.61%   53.96%   -0.65%     
==========================================
  Files         414      414              
  Lines       53516    53515       -1     
==========================================
- Hits        29228    28881     -347     
- Misses      21864    22199     +335     
- Partials     2424     2435      +11     
Impacted Files Coverage Δ
ledger/catchpointtracker.go 56.50% <75.00%> (-4.09%) ⬇️
util/db/dbutil.go 42.26% <100.00%> (-0.35%) ⬇️
crypto/onetimesig.go 0.00% <0.00%> (-76.07%) ⬇️
data/bookkeeping/txn_merkle.go 62.96% <0.00%> (-22.23%) ⬇️
data/account/participation.go 45.68% <0.00%> (-18.11%) ⬇️
crypto/rand.go 11.76% <0.00%> (-17.65%) ⬇️
data/transactions/logic/sourcemap.go 82.75% <0.00%> (-17.25%) ⬇️
stateproof/verify/stateproof.go 64.28% <0.00%> (-11.43%) ⬇️
ledger/internal/eval.go 39.35% <0.00%> (-9.64%) ⬇️
crypto/curve25519.go 56.36% <0.00%> (-5.46%) ⬇️
... and 26 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@brianolson brianolson left a comment

Choose a reason for hiding this comment

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

good simple change except I don't like the dbCtx -> ctx rename

@@ -1107,7 +1107,7 @@ func (ct *catchpointTracker) generateCatchpointData(ctx context.Context, account
var catchpointWriter *catchpointWriter
start := time.Now()
ledgerGeneratecatchpointCount.Inc(nil)
err := ct.dbs.Rdb.Atomic(func(dbCtx context.Context, tx *sql.Tx) (err error) {
err := ct.dbs.Rdb.AtomicContext(ctx, func(ctx context.Context, tx *sql.Tx) (err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is less clear because it shadows the outer function's param ctx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, fixed!

@algorandskiy algorandskiy merged commit 561bc4a into algorand:master Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants