Skip to content

refactor: remove sql.Tx from Batch#5080

Merged
algorandskiy merged 10 commits into
algorand:masterfrom
icorderi:refactor/store-atomic-3
Feb 17, 2023
Merged

refactor: remove sql.Tx from Batch#5080
algorandskiy merged 10 commits into
algorand:masterfrom
icorderi:refactor/store-atomic-3

Conversation

@icorderi
Copy link
Copy Markdown
Contributor

@icorderi icorderi commented Jan 30, 2023

Summary

  • removed the sql.Tx from the .Batch(..) callback.
  • removed the sql.Tx from the .Snapshot(..) callback.

This PR is part of a series:

Test Plan

Existing tests

@icorderi icorderi requested a review from algorandskiy January 30, 2023 20:35
@icorderi icorderi self-assigned this Jan 30, 2023
@icorderi icorderi force-pushed the refactor/store-atomic-3 branch 3 times, most recently from f51b8cb to 4957128 Compare February 6, 2023 19:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 8, 2023

Codecov Report

Merging #5080 (641a2e6) into master (eba02a6) will decrease coverage by 0.17%.
The diff coverage is 37.02%.

@@            Coverage Diff             @@
##           master    #5080      +/-   ##
==========================================
- Coverage   53.47%   53.31%   -0.17%     
==========================================
  Files         431      431              
  Lines       54373    54524     +151     
==========================================
- Hits        29076    29069       -7     
- Misses      23044    23170     +126     
- Partials     2253     2285      +32     
Impacted Files Coverage Δ
ledger/bulletin.go 93.75% <ø> (ø)
ledger/metrics.go 100.00% <ø> (ø)
ledger/notifier.go 88.57% <ø> (ø)
ledger/store/accountsV2.go 13.95% <0.00%> (-2.01%) ⬇️
ledger/store/encodedAccountsIter.go 0.00% <0.00%> (ø)
ledger/store/store.go 0.00% <0.00%> (ø)
ledger/store/testing.go 53.48% <0.00%> (-2.61%) ⬇️
util/db/dbutil.go 42.26% <ø> (ø)
ledger/acctdeltas.go 79.24% <45.45%> (-0.91%) ⬇️
ledger/txtail.go 76.31% <50.00%> (-2.21%) ⬇️
... and 22 more

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

@icorderi icorderi force-pushed the refactor/store-atomic-3 branch 2 times, most recently from 73f9855 to eb3c09b Compare February 8, 2023 17:42
@icorderi icorderi requested a review from AlgoAxel February 9, 2023 14:58
@icorderi icorderi marked this pull request as ready for review February 9, 2023 14:58
Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

I cannot find anything wrong with this PR although the fact many Create* functions now error and they did not before. This affects not only writing but reading as well so there is possibility for producing different results on upgraded and non-upgraded nodes. Need to re-examine this.

This PR also misses Create -> Make rename as discussed earlier, and two tests migration from ledger to catchpoints

Comment thread ledger/acctdeltas_test.go
Comment thread ledger/acctdeltas_test.go Outdated
Comment thread ledger/acctdeltas_test.go
require.True(t, allAccountsHaveStateProofPKs(accts))
dbs.Transaction(func(ctx context.Context, tx store.TransactionScope) (err error) {
accts := ledgertesting.RandomAccounts(20, false)
_ = tx.AccountsInitTest(t, accts, protocol.ConsensusCurrentVersion)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

idk but AccountsInitTest in TransactionScope looks a bit weird abstraction

Comment thread ledger/acctdeltas_test.go
func BenchmarkReadingRandomBalancesDisk(b *testing.B) {
benchmarkReadingRandomBalances(b, false)
}
func BenchmarkWritingRandomBalancesDisk(b *testing.B) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: this is was a basic benchmark showing sqlite performance. Maybe moving to store/sql_test.go or removing as a separate commit/PR

Comment thread ledger/acctonline.go Outdated
Comment thread ledger/catchpointwriter.go Outdated
Comment thread ledger/catchpointwriter_test.go
Comment thread ledger/catchpointwriter_test.go

// AccountsAllTest iterates the account table and returns a map of the data
// It is meant only for testing purposes - it is heavy and has no production use case.
func (r *accountsV2Reader) AccountsAllTest() (bals map[basics.Address]basics.AccountData, err error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: since this is part of an interface probably need a better name AccountsAllTest -> GetAllAccountsTesting or similar

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would suggest we can do a renaming pass on a few methods on a followup PR.

This name just follows the previous name it already had AcountsAll and adds Test to it to flag it as a testing only method.

Making it GetAllAccountTesting would add several naming convention changes.
I do prefer the name, but rather deal with several renames all at once than leave this one on its own.

@icorderi icorderi force-pushed the refactor/store-atomic-3 branch from a744e0b to 641a2e6 Compare February 16, 2023 16:43
Copy link
Copy Markdown
Contributor

@AlgoAxel AlgoAxel left a comment

Choose a reason for hiding this comment

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

Just took a once over, but as I am also working this branch, I am familiar with it and given the checks passing, am comfortable adding my approval. As I helped in development on this PR, if we'd like another reviewer that's fine, but lots of this work was done by Ignacio before I started adding.

Comment thread ledger/acctonline.go
@algorandskiy algorandskiy merged commit b84f980 into algorand:master Feb 17, 2023

func makeCatchpointWriter(ctx context.Context, filePath string, tx *sql.Tx, maxResourcesPerChunk int) (*catchpointWriter, error) {
arw := store.NewAccountsSQLReaderWriter(tx)
func makeCatchpointWriter(ctx context.Context, filePath string, tx store.TransactionScope, maxResourcesPerChunk int) (*catchpointWriter, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in #5583

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.

4 participants