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

Optimise db performance of GetLedgerRange #256

Merged
merged 46 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c795d8c
Use GetLedgerRange to get the latest ledger
aditya1702 Jul 26, 2024
dd009c8
Remove latestLedger key from meta table
aditya1702 Jul 26, 2024
096c434
Remove latestLedger key from meta table - 2
aditya1702 Jul 29, 2024
1395472
Merge branch 'main' into ledger-range-cache
aditya1702 Jul 29, 2024
a8190eb
Fix failing unittest - 1
aditya1702 Jul 29, 2024
30a261e
Remove cache check condition
aditya1702 Jul 29, 2024
6375518
Fix failing unittest - 2
aditya1702 Jul 29, 2024
943b01d
Uncomment failing ledger entry test
aditya1702 Jul 29, 2024
557ab81
Remove db.SessionInterface param
aditya1702 Jul 29, 2024
3928831
Fix failing unittest
aditya1702 Aug 1, 2024
4d030da
Cache ledger range - 1
aditya1702 Aug 2, 2024
9346660
Cache ledger range - 2
aditya1702 Aug 2, 2024
f47fe65
Cache ledger range - 3
aditya1702 Aug 2, 2024
a81e0cf
Cache ledger range - 4
aditya1702 Aug 5, 2024
1b41b5b
Fix failing test
aditya1702 Aug 5, 2024
bb06fdf
Fix failing test - 2
aditya1702 Aug 5, 2024
844d46b
Fix linting - 1
aditya1702 Aug 6, 2024
b4ec665
Fix linting - 2
aditya1702 Aug 6, 2024
c07bb2f
Reduce the time further
aditya1702 Aug 6, 2024
1dcb540
Remove creating transaction for GetLedgerRange
aditya1702 Aug 12, 2024
07a753b
Remove creating transaction for GetLedgerRange - 2
aditya1702 Aug 12, 2024
c7ce36b
Remove creating transaction for GetLedgerRange - 3
aditya1702 Aug 12, 2024
6f0b8dd
Fix failing unittest - 1
aditya1702 Aug 12, 2024
ec749d0
Fix failing tests - 2
aditya1702 Aug 12, 2024
9229df4
Update cmd/soroban-rpc/internal/db/ledger.go
aditya1702 Aug 12, 2024
4696a6b
Add check for empty result in ledger range
aditya1702 Aug 12, 2024
896a7b6
Merge branch 'main' into ledger-range-cache
aditya1702 Aug 12, 2024
f5a2ff0
Merge remote-tracking branch 'origin/ledger-range-cache' into ledger-…
aditya1702 Aug 12, 2024
19b3989
Add a cache check on GetLatestLedgerSequence call
aditya1702 Aug 13, 2024
288e446
Move cache read to DB function
aditya1702 Aug 13, 2024
f7ebe3e
Move cache read to DB function - 2
aditya1702 Aug 13, 2024
bc07626
Revert "Move cache read to DB function - 2"
aditya1702 Aug 13, 2024
bf1586e
Merge remote-tracking branch 'refs/remotes/upstream/main' into ledger…
aditya1702 Aug 26, 2024
3d8f4b8
Lock cache before creating tx
aditya1702 Aug 26, 2024
456e2e1
Fix failing test
aditya1702 Aug 26, 2024
9ff55a6
Add migration
aditya1702 Aug 26, 2024
5c3a4e9
Fix failing test
aditya1702 Aug 27, 2024
d1267e3
Merge branch 'main' into ledger-range-cache
aditya1702 Aug 28, 2024
a437b0e
Refactor NewTx and NewCachedTx
aditya1702 Aug 28, 2024
3caab2f
Merge remote-tracking branch 'origin/ledger-range-cache' into ledger-…
aditya1702 Aug 28, 2024
1f44abe
Merge branch 'main' into ledger-range-cache
aditya1702 Aug 28, 2024
3957352
Refactor NewTx and NewCachedTx - 2
aditya1702 Aug 28, 2024
0ec8237
Refactor NewTx and NewCachedTx - 3
aditya1702 Aug 28, 2024
5f215d2
Merge remote-tracking branch 'refs/remotes/upstream/main' into ledger…
aditya1702 Sep 4, 2024
ccd80f1
Refactor NewTx and NewCachedTx - 4
aditya1702 Sep 4, 2024
7d14a09
Merge branch 'main' into ledger-range-cache
aditya1702 Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions cmd/soroban-rpc/internal/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ var sqlMigrations embed.FS
var ErrEmptyDB = errors.New("DB is empty")

const (
metaTableName = "metadata"
latestLedgerSequenceMetaKey = "LatestLedgerSequence"
metaTableName = "metadata"
)

type ReadWriter interface {
Expand All @@ -42,13 +41,14 @@ type WriteTx interface {
LedgerEntryWriter() LedgerEntryWriter
LedgerWriter() LedgerWriter

Commit(ledgerSeq uint32) error
Commit(ledgerCloseMeta xdr.LedgerCloseMeta) error
Rollback() error
}

type dbCache struct {
latestLedgerSeq uint32
ledgerEntries transactionalCache // Just like the DB: compress-encoded ledger key -> ledger entry XDR
latestLedgerSeq uint32
latestLedgerCloseTime int64
ledgerEntries transactionalCache // Just like the DB: compress-encoded ledger key -> ledger entry XDR
sync.RWMutex
}

Expand Down Expand Up @@ -129,33 +129,37 @@ func getMetaValue(ctx context.Context, q db.SessionInterface, key string) (strin
case 1:
// expected length on an initialized DB
default:
return "", fmt.Errorf("multiple entries (%d) for key %q in table %q", len(results), latestLedgerSequenceMetaKey, metaTableName)
return "", fmt.Errorf("multiple entries (%d) for key %q in table %q", len(results), key, metaTableName)
}
return results[0], nil
}

func getLatestLedgerSequence(ctx context.Context, q db.SessionInterface, cache *dbCache) (uint32, error) {
latestLedgerStr, err := getMetaValue(ctx, q, latestLedgerSequenceMetaKey)
if err != nil {
return 0, err
func getLatestLedgerSequence(ctx context.Context, ledgerReader LedgerReader, cache *dbCache) (uint32, error) {
cache.RLock()
latestLedgerSeqCache := cache.latestLedgerSeq
cache.RUnlock()

if latestLedgerSeqCache != 0 {
return latestLedgerSeqCache, nil
}
2opremio marked this conversation as resolved.
Show resolved Hide resolved
latestLedger, err := strconv.ParseUint(latestLedgerStr, 10, 32)

ledgerRange, err := ledgerReader.GetLedgerRange(ctx)
aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return 0, err
}
result := uint32(latestLedger)

// Add missing ledger sequence to the top cache.
// Add missing ledger sequence and close time to the top cache.
// Otherwise, the write-through cache won't get updated until the first ingestion commit
cache.Lock()
if cache.latestLedgerSeq == 0 {
// Only update the cache if the value is missing (0), otherwise
// we may end up overwriting the entry with an older version
cache.latestLedgerSeq = result
cache.latestLedgerSeq = ledgerRange.LastLedger.Sequence
cache.latestLedgerCloseTime = ledgerRange.LastLedger.CloseTime
}
cache.Unlock()

return result, nil
return ledgerRange.LastLedger.Sequence, nil
}

type ReadWriterMetrics struct {
Expand Down Expand Up @@ -216,7 +220,7 @@ func NewReadWriter(
}

func (rw *readWriter) GetLatestLedgerSequence(ctx context.Context) (uint32, error) {
return getLatestLedgerSequence(ctx, rw.db, rw.db.cache)
return getLatestLedgerSequence(ctx, NewLedgerReader(rw.db), rw.db.cache)
}

func (rw *readWriter) NewTx(ctx context.Context) (WriteTx, error) {
Expand Down Expand Up @@ -293,7 +297,10 @@ func (w writeTx) EventWriter() EventWriter {
return &w.eventWriter
}

func (w writeTx) Commit(ledgerSeq uint32) error {
func (w writeTx) Commit(ledgerCloseMeta xdr.LedgerCloseMeta) error {
ledgerSeq := ledgerCloseMeta.LedgerSequence()
ledgerCloseTime := ledgerCloseMeta.LedgerCloseTime()

if err := w.ledgerEntryWriter.flush(); err != nil {
return err
}
Expand All @@ -309,24 +316,17 @@ func (w writeTx) Commit(ledgerSeq uint32) error {
return err
}

_, err := sq.Replace(metaTableName).
Values(latestLedgerSequenceMetaKey, strconv.FormatUint(uint64(ledgerSeq), 10)).
RunWith(w.stmtCache).
Exec()
if err != nil {
return err
}

// We need to make the cache update atomic with the transaction commit.
// Otherwise, the cache can be made inconsistent if a write transaction finishes
// in between, updating the cache in the wrong order.
commitAndUpdateCache := func() error {
w.globalCache.Lock()
defer w.globalCache.Unlock()
if err = w.tx.Commit(); err != nil {
if err := w.tx.Commit(); err != nil {
return err
}
w.globalCache.latestLedgerSeq = ledgerSeq
w.globalCache.latestLedgerCloseTime = ledgerCloseTime
w.ledgerEntryWriter.ledgerEntryCacheWriteTx.commit()
return nil
}
Expand Down
36 changes: 34 additions & 2 deletions cmd/soroban-rpc/internal/db/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,39 @@ func (r ledgerReader) GetLedger(ctx context.Context, sequence uint32) (xdr.Ledge

// GetLedgerRange pulls the min/max ledger sequence numbers from the meta table.
func (r ledgerReader) GetLedgerRange(ctx context.Context) (ledgerbucketwindow.LedgerRange, error) {
r.db.cache.RLock()
latestLedgerSeqCache := r.db.cache.latestLedgerSeq
latestLedgerCloseTimeCache := r.db.cache.latestLedgerCloseTime
r.db.cache.RUnlock()

// Make use of the cached latest ledger seq and close time to query only the oldest ledger details.
if latestLedgerSeqCache != 0 {
query := sq.Select("meta").
From(ledgerCloseMetaTableName).
Where(
fmt.Sprintf("sequence = (SELECT MIN(sequence) FROM %s)", ledgerCloseMetaTableName),
)
var lcm []xdr.LedgerCloseMeta
if err := r.db.Select(ctx, &lcm, query); err != nil {
return ledgerbucketwindow.LedgerRange{}, fmt.Errorf("couldn't query ledger range: %w", err)
}

if len(lcm) == 0 {
return ledgerbucketwindow.LedgerRange{}, ErrEmptyDB
}

return ledgerbucketwindow.LedgerRange{
FirstLedger: ledgerbucketwindow.LedgerInfo{
Sequence: lcm[0].LedgerSequence(),
aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
CloseTime: lcm[0].LedgerCloseTime(),
},
LastLedger: ledgerbucketwindow.LedgerInfo{
Sequence: latestLedgerSeqCache,
CloseTime: latestLedgerCloseTimeCache,
},
}, nil
}

aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
query := sq.Select("lcm.meta").
From(ledgerCloseMetaTableName + " as lcm").
Where(sq.Or{
Expand All @@ -117,9 +150,8 @@ func (r ledgerReader) GetLedgerRange(ctx context.Context) (ledgerbucketwindow.Le
return ledgerbucketwindow.LedgerRange{}, fmt.Errorf("couldn't query ledger range: %w", err)
}

// Empty DB
if len(lcms) == 0 {
return ledgerbucketwindow.LedgerRange{}, nil
return ledgerbucketwindow.LedgerRange{}, ErrEmptyDB
}

return ledgerbucketwindow.LedgerRange{
Expand Down
24 changes: 14 additions & 10 deletions cmd/soroban-rpc/internal/db/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ func TestLedgers(t *testing.T) {
ledgerSequence := uint32(i)
tx, err := NewReadWriter(logger, db, daemon, 150, 15, passphrase).NewTx(context.Background())
require.NoError(t, err)
require.NoError(t, tx.LedgerWriter().InsertLedger(createLedger(ledgerSequence)))
require.NoError(t, tx.Commit(ledgerSequence))

ledgerCloseMeta := createLedger(ledgerSequence)
require.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
require.NoError(t, tx.Commit(ledgerCloseMeta))
// rolling back after a commit is a no-op
require.NoError(t, tx.Rollback())
}
Expand All @@ -92,16 +94,18 @@ func TestLedgers(t *testing.T) {
ledgerSequence := uint32(11)
tx, err := NewReadWriter(logger, db, daemon, 150, 15, passphrase).NewTx(context.Background())
require.NoError(t, err)
require.NoError(t, tx.LedgerWriter().InsertLedger(createLedger(ledgerSequence)))
require.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta := createLedger(ledgerSequence)
require.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
require.NoError(t, tx.Commit(ledgerCloseMeta))

assertLedgerRange(t, reader, 1, 11)

ledgerSequence = uint32(12)
tx, err = NewReadWriter(logger, db, daemon, 150, 5, passphrase).NewTx(context.Background())
require.NoError(t, err)
require.NoError(t, tx.LedgerWriter().InsertLedger(createLedger(ledgerSequence)))
require.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta = createLedger(ledgerSequence)
require.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
require.NoError(t, tx.Commit(ledgerCloseMeta))

assertLedgerRange(t, reader, 8, 12)
}
Expand All @@ -126,7 +130,7 @@ func TestGetLedgerRange_NonEmptyDB(t *testing.T) {
require.NoError(t, ledgerW.InsertLedger(lcm), "ingestion failed for ledger %+v", lcm.V1)
require.NoError(t, txW.InsertTransactions(lcm), "ingestion failed for ledger %+v", lcm.V1)
}
require.NoError(t, write.Commit(lcms[len(lcms)-1].LedgerSequence()))
require.NoError(t, write.Commit(lcms[len(lcms)-1]))

reader := NewLedgerReader(db)
ledgerRange, err := reader.GetLedgerRange(ctx)
Expand Down Expand Up @@ -154,7 +158,7 @@ func TestGetLedgerRange_SingleDBRow(t *testing.T) {
require.NoError(t, ledgerW.InsertLedger(lcm), "ingestion failed for ledger %+v", lcm.V1)
require.NoError(t, txW.InsertTransactions(lcm), "ingestion failed for ledger %+v", lcm.V1)
}
require.NoError(t, write.Commit(lcms[len(lcms)-1].LedgerSequence()))
require.NoError(t, write.Commit(lcms[len(lcms)-1]))

reader := NewLedgerReader(db)
ledgerRange, err := reader.GetLedgerRange(ctx)
Expand All @@ -171,7 +175,7 @@ func TestGetLedgerRange_EmptyDB(t *testing.T) {

reader := NewLedgerReader(db)
ledgerRange, err := reader.GetLedgerRange(ctx)
require.NoError(t, err)
assert.Equal(t, ErrEmptyDB, err)
assert.Equal(t, uint32(0), ledgerRange.FirstLedger.Sequence)
assert.Equal(t, int64(0), ledgerRange.FirstLedger.CloseTime)
assert.Equal(t, uint32(0), ledgerRange.LastLedger.Sequence)
Expand All @@ -196,7 +200,7 @@ func BenchmarkGetLedgerRange(b *testing.B) {
require.NoError(b, ledgerW.InsertLedger(lcm))
require.NoError(b, txW.InsertTransactions(lcm))
}
require.NoError(b, write.Commit(lcms[len(lcms)-1].LedgerSequence()))
require.NoError(b, write.Commit(lcms[len(lcms)-1]))
reader := NewLedgerReader(db)

b.ResetTimer()
Expand Down
9 changes: 6 additions & 3 deletions cmd/soroban-rpc/internal/db/ledgerentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ type ledgerEntryReadTx struct {
stmtCache *sq.StmtCache
latestLedgerSeqCache uint32
ledgerEntryCacheReadTx *transactionalCacheReadTx
ledgerReader LedgerReader
tx db.SessionInterface
buffer *xdr.EncodingBuffer
}
Expand All @@ -148,7 +149,7 @@ func (l *ledgerEntryReadTx) GetLatestLedgerSequence() (uint32, error) {
if l.latestLedgerSeqCache != 0 {
return l.latestLedgerSeqCache, nil
}
latestLedgerSeq, err := getLatestLedgerSequence(context.Background(), l.tx, l.globalCache)
latestLedgerSeq, err := getLatestLedgerSequence(context.Background(), l.ledgerReader, l.globalCache)
if err == nil {
l.latestLedgerSeqCache = latestLedgerSeq
}
aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -341,7 +342,7 @@ func NewLedgerEntryReader(db *DB) LedgerEntryReader {
}

func (r ledgerEntryReader) GetLatestLedgerSequence(ctx context.Context) (uint32, error) {
return getLatestLedgerSequence(ctx, r.db, r.db.cache)
return getLatestLedgerSequence(ctx, NewLedgerReader(r.db), r.db.cache)
}

// NewCachedTx() caches all accessed ledger entries and select statements. If many ledger entries are accessed, it will grow without bounds.
Expand All @@ -364,22 +365,24 @@ func (r ledgerEntryReader) NewCachedTx(ctx context.Context) (LedgerEntryReadTx,
stmtCache: sq.NewStmtCache(txSession.GetTx()),
latestLedgerSeqCache: r.db.cache.latestLedgerSeq,
ledgerEntryCacheReadTx: &cacheReadTx,
ledgerReader: NewLedgerReader(r.db),
tx: txSession,
buffer: xdr.NewEncodingBuffer(),
}, nil
}

func (r ledgerEntryReader) NewTx(ctx context.Context) (LedgerEntryReadTx, error) {
txSession := r.db.Clone()
r.db.cache.RLock()
if err := txSession.BeginTx(ctx, &sql.TxOptions{ReadOnly: true}); err != nil {
return nil, err
}
r.db.cache.RLock()
defer r.db.cache.RUnlock()
aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
return &ledgerEntryReadTx{
globalCache: r.db.cache,
latestLedgerSeqCache: r.db.cache.latestLedgerSeq,
tx: txSession,
ledgerReader: NewLedgerReader(r.db),
buffer: xdr.NewEncodingBuffer(),
}, nil
}
Expand Down
34 changes: 23 additions & 11 deletions cmd/soroban-rpc/internal/db/ledgerentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func TestGoldenPath(t *testing.T) {
assert.NoError(t, writer.UpsertLedgerEntry(expLegerEntry))

ledgerSequence := uint32(23)
assert.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta := createLedger(ledgerSequence)
assert.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
assert.NoError(t, tx.Commit(ledgerCloseMeta))

present, obtainedEntry, obtainedLedgerSequence, liveUntilSeq := getLedgerEntryAndLatestLedgerSequence(t, db, key)
assert.True(t, present)
Expand All @@ -113,7 +115,9 @@ func TestGoldenPath(t *testing.T) {
assert.NoError(t, writer.UpsertLedgerEntry(entry))

ledgerSequence = uint32(24)
assert.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta = createLedger(ledgerSequence)
assert.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
assert.NoError(t, tx.Commit(ledgerCloseMeta))

present, obtainedEntry, obtainedLedgerSequence, liveUntilSeq = getLedgerEntryAndLatestLedgerSequence(t, db, key)
assert.True(t, present)
Expand All @@ -129,7 +133,9 @@ func TestGoldenPath(t *testing.T) {

assert.NoError(t, writer.DeleteLedgerEntry(key))
ledgerSequence = uint32(25)
assert.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta = createLedger(ledgerSequence)
assert.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
assert.NoError(t, tx.Commit(ledgerCloseMeta))

present, _, obtainedLedgerSequence, liveUntilSeq = getLedgerEntryAndLatestLedgerSequence(t, db, key)
assert.False(t, present)
Expand Down Expand Up @@ -170,7 +176,9 @@ func TestDeleteNonExistentLedgerEmpty(t *testing.T) {
key, _ := getContractDataLedgerEntry(t, data)
assert.NoError(t, writer.DeleteLedgerEntry(key))
ledgerSequence := uint32(23)
assert.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta := createLedger(ledgerSequence)
assert.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
assert.NoError(t, tx.Commit(ledgerCloseMeta))

// Make sure that the ledger number was submitted
obtainedLedgerSequence, err := NewLedgerEntryReader(db).GetLatestLedgerSequence(context.Background())
Expand Down Expand Up @@ -271,7 +279,9 @@ func TestReadTxsDuringWriteTx(t *testing.T) {

// Finish the write transaction and check that the results are present
ledgerSequence := uint32(23)
assert.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta := createLedger(ledgerSequence)
assert.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
assert.NoError(t, tx.Commit(ledgerCloseMeta))

obtainedLedgerSequence, err := NewLedgerEntryReader(db).GetLatestLedgerSequence(context.Background())
assert.NoError(t, err)
Expand Down Expand Up @@ -348,11 +358,11 @@ func TestWriteTxsDuringReadTxs(t *testing.T) {

// commit the write transaction
ledgerSequence := uint32(23)
assert.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta := createLedger(ledgerSequence)
assert.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
assert.NoError(t, tx.Commit(ledgerCloseMeta))

for _, readTx := range []LedgerEntryReadTx{readTx1, readTx2, readTx3} {
_, err = readTx.GetLatestLedgerSequence()
assert.Equal(t, ErrEmptyDB, err)
present, _, _, err := GetLedgerEntry(readTx, key)
assert.NoError(t, err)
assert.False(t, present)
Expand Down Expand Up @@ -416,7 +426,9 @@ func TestConcurrentReadersAndWriter(t *testing.T) {
expLegerEntry := getTTLLedgerEntry(expLedgerKey)
assert.NoError(t, writer.UpsertLedgerEntry(expLegerEntry))
}
assert.NoError(t, tx.Commit(ledgerSequence))
ledgerCloseMeta := createLedger(ledgerSequence)
assert.NoError(t, tx.LedgerWriter().InsertLedger(ledgerCloseMeta))
assert.NoError(t, tx.Commit(ledgerCloseMeta))
logMessageCh <- fmt.Sprintf("Wrote ledger %d", ledgerSequence)
time.Sleep(time.Duration(rand.Int31n(30)) * time.Millisecond)
}
Expand Down Expand Up @@ -511,7 +523,7 @@ func benchmarkLedgerEntry(b *testing.B, cached bool) {
expLedgerKey, err := entryKeyToTTLEntryKey(key)
assert.NoError(b, err)
assert.NoError(b, tx.LedgerEntryWriter().UpsertLedgerEntry(getTTLLedgerEntry(expLedgerKey)))
assert.NoError(b, tx.Commit(2))
assert.NoError(b, tx.Commit(createLedger(2)))
reader := NewLedgerEntryReader(db)
const numQueriesPerOp = 15
b.ResetTimer()
Expand Down Expand Up @@ -570,6 +582,6 @@ func BenchmarkLedgerUpdate(b *testing.B) {
keyUint32 = xdr.Uint32(j)
assert.NoError(b, writer.UpsertLedgerEntry(entry))
}
assert.NoError(b, tx.Commit(uint32(i+1)))
assert.NoError(b, tx.Commit(createLedger(uint32(i+1))))
}
}
Loading
Loading