From 98e73b36bd87522c76bd710a9788a0238f1e90ac Mon Sep 17 00:00:00 2001 From: Andy Arthur Date: Tue, 20 Dec 2022 14:09:14 -0800 Subject: [PATCH] chunk journal now implements manifestGCGenUpdater --- go/store/nbs/chunk_journal.go | 22 +++++++++++++++++-- .../bats/garbage_collection.bats | 8 +++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/go/store/nbs/chunk_journal.go b/go/store/nbs/chunk_journal.go index e7eb80d7d7..ba9bdf4697 100644 --- a/go/store/nbs/chunk_journal.go +++ b/go/store/nbs/chunk_journal.go @@ -30,7 +30,7 @@ import ( "github.com/dolthub/dolt/go/store/hash" ) -var ChunkJournalFeatureFlag = false +var ChunkJournalFeatureFlag = true func init() { if os.Getenv("DOLT_ENABLE_CHUNK_JOURNAL") != "" { @@ -56,6 +56,7 @@ var _ tablePersister = &chunkJournal{} var _ tableFilePersister = &chunkJournal{} var _ manifest = &chunkJournal{} +var _ manifestGCGenUpdater = &chunkJournal{} var _ io.Closer = &chunkJournal{} type journalChunkSource struct { @@ -229,7 +230,7 @@ func (j *chunkJournal) Update(ctx context.Context, lastLock addr, next manifestC } if j.contents.gcGen != next.gcGen { - return manifestContents{}, errors.New("chunkJournal cannot update GC generation") + return manifestContents{}, errors.New("use UpdateGCGen to update GC generation") } else if j.contents.lock != lastLock { return j.contents, nil // |next| is stale } @@ -248,6 +249,23 @@ func (j *chunkJournal) Update(ctx context.Context, lastLock addr, next manifestC return j.contents, nil } +// UpdateGCGen implements manifestGCGenUpdater. +func (j *chunkJournal) UpdateGCGen(ctx context.Context, lastLock addr, next manifestContents, stats *Stats, writeHook func() error) (manifestContents, error) { + updater, ok := j.backing.(manifestGCGenUpdater) + if !ok { + err := fmt.Errorf("backing manifest (%s) does not support garbage collection", j.backing.Name()) + return manifestContents{}, err + } + + latest, err := updater.UpdateGCGen(ctx, lastLock, next, stats, writeHook) + if err != nil { + return manifestContents{}, err + } else if latest.root == next.root { + j.contents = next // success + } + return latest, nil +} + // ParseIfExists implements manifest. func (j *chunkJournal) ParseIfExists(ctx context.Context, stats *Stats, readHook func() error) (ok bool, mc manifestContents, err error) { if j.journal == nil { diff --git a/integration-tests/bats/garbage_collection.bats b/integration-tests/bats/garbage_collection.bats index 6b3b355036..88efa29987 100644 --- a/integration-tests/bats/garbage_collection.bats +++ b/integration-tests/bats/garbage_collection.bats @@ -291,7 +291,14 @@ SQL [[ "$output" =~ "$NUM_COMMITS" ]] || false } +skip_if_chunk_journal() { + if test -f "./.dolt/noms/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"; then + skip "chunk journal doesn't generate enough garbage" + fi +} + @test "garbage_collection: shallow gc" { + skip_if_chunk_journal create_many_commits # leave data in the working set @@ -314,6 +321,7 @@ SQL } @test "garbage_collection: online shallow gc" { + skip_if_chunk_journal create_many_commits # leave data in the working set