mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-06 18:59:02 -06:00
chunk journal now implements manifestGCGenUpdater
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user