Rebase on transaction start

This commit is contained in:
Zach Musgrave
2021-09-20 10:12:24 -07:00
parent b469648309
commit be6a441ede
2 changed files with 12 additions and 0 deletions

View File

@@ -1129,6 +1129,12 @@ func (ddb *DoltDB) DeleteWorkspace(ctx context.Context, workRef ref.DoltRef) err
return err
}
// Rebase rebases the underlying db from disk, re-loading the manifest. Useful when another process might have made
// changes to the database we need to read.
func (ddb *DoltDB) Rebase(ctx context.Context) error {
return ddb.db.Rebase(ctx)
}
// GC performs garbage collection on this ddb. Values passed in |uncommitedVals| will be temporarily saved during gc.
func (ddb *DoltDB) GC(ctx context.Context, uncommitedVals ...hash.Hash) error {
collector, ok := ddb.db.(datas.GarbageCollector)

View File

@@ -281,8 +281,14 @@ func (sess *Session) StartTransaction(ctx *sql.Context, dbName string) (sql.Tran
return DisabledTransaction{}, nil
}
err = sessionState.dbData.Ddb.Rebase(ctx)
if err != nil {
return nil, err
}
wsRef := sessionState.WorkingSet.Ref()
ws, err := sessionState.dbData.Ddb.ResolveWorkingSet(ctx, wsRef)
// TODO: every HEAD needs a working set created when it is. We can get rid of this in a 1.0 release when this is fixed
if err == doltdb.ErrWorkingSetNotFound {
ws, err = sess.newWorkingSetForHead(ctx, wsRef, dbName)
if err != nil {