mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-09 10:38:10 -06:00
Rollback working, savepoints still busted due to table caching
This commit is contained in:
@@ -18,7 +18,7 @@ require (
|
||||
github.com/denisbrodbeck/machineid v1.0.1
|
||||
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20201005193433-3ee972b1d078
|
||||
github.com/dolthub/fslock v0.0.2
|
||||
github.com/dolthub/go-mysql-server v0.9.1-0.20210510171812-e46361526135
|
||||
github.com/dolthub/go-mysql-server v0.9.1-0.20210511220131-6b5298f6fed8
|
||||
github.com/dolthub/ishell v0.0.0-20210205014355-16a4ce758446
|
||||
github.com/dolthub/mmap-go v1.0.4-0.20201107010347-f9f2a9588a66
|
||||
github.com/dolthub/sqllogictest/go v0.0.0-20201105013724-5123fc66e12c
|
||||
|
||||
@@ -109,7 +109,7 @@ func (db Database) CommitTransaction(ctx *sql.Context, tx sql.Transaction) error
|
||||
|
||||
func (db Database) Rollback(ctx *sql.Context, tx sql.Transaction) error {
|
||||
dsession := DSessFromSess(ctx.Session)
|
||||
return dsession.CommitTransaction(ctx, db.name, tx)
|
||||
return dsession.RollbackTransaction(ctx, db.name, tx)
|
||||
}
|
||||
|
||||
func (db Database) CreateSavepoint(ctx *sql.Context, tx sql.Transaction, name string) error {
|
||||
|
||||
@@ -249,8 +249,7 @@ func (sess *DoltSession) RollbackToSavepoint(ctx *sql.Context, savepointName, db
|
||||
|
||||
root := dtx.GetSavepoint(savepointName)
|
||||
if root == nil {
|
||||
// TODO: sql namespace error
|
||||
return fmt.Errorf("no savepoint found with name %s", savepointName)
|
||||
return sql.ErrSavepointDoesNotExist.New(savepointName)
|
||||
}
|
||||
|
||||
return sess.SetRoot(ctx, dbName, root)
|
||||
@@ -270,8 +269,7 @@ func (sess *DoltSession) ReleaseSavepoint(ctx *sql.Context, savepointName, dbNam
|
||||
|
||||
root := dtx.ClearSavepoint(savepointName)
|
||||
if root == nil {
|
||||
// TODO: sql namespace error
|
||||
return fmt.Errorf("no savepoint found with name %s", savepointName)
|
||||
return sql.ErrSavepointDoesNotExist.New(savepointName)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -45,6 +45,7 @@ func NewDoltTransaction(startRoot *doltdb.RootValue, workingSet ref.WorkingSetRe
|
||||
workingSet: workingSet,
|
||||
db: db,
|
||||
rsw: rsw,
|
||||
savepoints: make(map[string]*doltdb.RootValue),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ func (tx *DoltTransaction) Commit(ctx *sql.Context, newRoot *doltdb.RootValue) (
|
||||
continue
|
||||
}
|
||||
|
||||
return newRoot, nil
|
||||
return tx.updateRepoStateFile(ctx, newRoot)
|
||||
}
|
||||
|
||||
mergedRoot, stats, err := merge.MergeRoots(ctx, root, newRoot, tx.startRoot)
|
||||
@@ -110,14 +111,14 @@ func (tx *DoltTransaction) Commit(ctx *sql.Context, newRoot *doltdb.RootValue) (
|
||||
|
||||
// TODO: this is not thread safe, but will not be necessary after migrating all clients away from using the
|
||||
// working set stored in repo_state.json, so should be good enough for now
|
||||
return tx.updateRepoStateFile(ctx, mergedRoot, err)
|
||||
return tx.updateRepoStateFile(ctx, mergedRoot)
|
||||
}
|
||||
|
||||
// TODO: different error type for retries exhausted
|
||||
return nil, datas.ErrOptimisticLockFailed
|
||||
}
|
||||
|
||||
func (tx *DoltTransaction) updateRepoStateFile(ctx *sql.Context, mergedRoot *doltdb.RootValue, err error) (*doltdb.RootValue, error) {
|
||||
func (tx *DoltTransaction) updateRepoStateFile(ctx *sql.Context, mergedRoot *doltdb.RootValue) (*doltdb.RootValue, error) {
|
||||
hash, err := mergedRoot.HashOf()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user