chunk journal now implements manifestGCGenUpdater

This commit is contained in:
Andy Arthur
2022-12-20 14:09:14 -08:00
parent 9c62afd73b
commit 98e73b36bd
2 changed files with 28 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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