validate ws migration, skip table validation if table did not change (#4630)

This commit is contained in:
Dhruv Sringari
2022-10-26 13:07:40 -07:00
committed by GitHub
parent 4157c40061
commit a787f5baff
2 changed files with 31 additions and 2 deletions
+11 -1
View File
@@ -74,6 +74,16 @@ func migrateWorkingSet(ctx context.Context, brRef ref.BranchRef, wsRef ref.Worki
return err
}
err = validateRootValue(ctx, oldHeadRoot, oldWs.WorkingRoot(), wr)
if err != nil {
return err
}
err = validateRootValue(ctx, oldHeadRoot, oldWs.StagedRoot(), sr)
if err != nil {
return err
}
newWs := doltdb.EmptyWorkingSet(wsRef).WithWorkingRoot(wr).WithStagedRoot(sr)
return new.UpdateWorkingSet(ctx, wsRef, newWs, hash.Hash{}, oldWs.Meta())
@@ -179,7 +189,7 @@ func migrateCommit(ctx context.Context, oldCm *doltdb.Commit, new *doltdb.DoltDB
// validate root after we flush the ChunkStore to facilitate
// investigating failed migrations
if err = validateRootValue(ctx, oldRoot, mRoot); err != nil {
if err = validateRootValue(ctx, oldParentRoot, oldRoot, mRoot); err != nil {
return err
}
+20 -1
View File
@@ -52,7 +52,7 @@ func validateBranchMapping(ctx context.Context, old, new *doltdb.DoltDB) error {
return nil
}
func validateRootValue(ctx context.Context, old, new *doltdb.RootValue) error {
func validateRootValue(ctx context.Context, oldParent, old, new *doltdb.RootValue) error {
names, err := old.GetTableNames(ctx)
if err != nil {
return err
@@ -67,6 +67,25 @@ func validateRootValue(ctx context.Context, old, new *doltdb.RootValue) error {
return fmt.Errorf("expected to find table %s in root value (%s)", name, h.String())
}
// Skip tables that haven't changed
op, ok, err := oldParent.GetTable(ctx, name)
if err != nil {
return err
}
if ok {
oldHash, err := o.HashOf()
if err != nil {
return err
}
oldParentHash, err := op.HashOf()
if err != nil {
return err
}
if oldHash.Equal(oldParentHash) {
continue
}
}
n, ok, err := new.GetTable(ctx, name)
if err != nil {
return err