-
Notifications
You must be signed in to change notification settings - Fork 451
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
refactor: abstract store and remove all db.Atomic
usage
#5021
Conversation
161daf3
to
4d59692
Compare
f46c110
to
dac797c
Compare
Codecov Report
@@ Coverage Diff @@
## master #5021 +/- ##
==========================================
- Coverage 53.57% 53.53% -0.05%
==========================================
Files 430 431 +1
Lines 54091 54120 +29
==========================================
- Hits 28980 28971 -9
- Misses 22864 22900 +36
- Partials 2247 2249 +2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -1292,7 +1292,7 @@ func TestAcctOnlineVotersLongerHistory(t *testing.T) { | |||
// DB has all the required history tho | |||
var dbOnlineRoundParams []ledgercore.OnlineRoundParamsData | |||
var endRound basics.Round | |||
err = oa.dbs.Rdb.Atomic(func(ctx context.Context, tx *sql.Tx) (err error) { | |||
err = oa.dbs.Batch(func(ctx context.Context, tx *sql.Tx) (err error) { |
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.
Snapshot? AccountsOnlineRoundParams is part of accountsV2Reader
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.
we will sort out snapshot, batch, transaction on the PR I'm work on on right now based on what methods they end up calling.
The PR I'm working on gets rid of that tx *sql.Tx
in the callbacks in favor of using interfaces with the methods we have defined already.
@@ -167,7 +166,7 @@ func (ml *mockLedgerForTracker) fork(t testing.TB) *mockLedgerForTracker { | |||
dbs.Rdb.SetLogger(dblogger) | |||
dbs.Wdb.SetLogger(dblogger) | |||
|
|||
newLedgerTracker.dbs = dbs | |||
newLedgerTracker.dbs = store.CreateTrackerSQLStore(dbs) |
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 go prefers Make/New prefix instead of Create for such functions
@@ -1090,7 +1087,7 @@ func (ct *catchpointTracker) generateCatchpointData(ctx context.Context, account | |||
var catchpointWriter *catchpointWriter | |||
start := time.Now() | |||
ledgerGeneratecatchpointCount.Inc(nil) | |||
err = ct.dbs.Rdb.AtomicContext(ctx, func(dbCtx context.Context, tx *sql.Tx) (err error) { | |||
err = ct.dbs.BatchContext(ctx, func(dbCtx context.Context, tx *sql.Tx) (err error) { |
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.
Fixed in #5583
Summary
db.Pair
and/ordb.Accessor
for the trackerdb/catchpoints has been removed.Transaction
(atomic read+write),Snapshot
(isolated reads),Batch
(all or nothing writes)Upcoming PRs:
Transaction
in favor of eitherSnapshot
orBatch
.*sql.Tx
exposed in this functions to be only the already defined "reader/writer" abstarctions.Test Plan
Existing tests.