mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-08 11:21:17 -05:00
validate ws migration, skip table validation if table did not change (#4630)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user