Caching bug fix

This commit is contained in:
Zach Musgrave
2023-06-06 10:09:54 -07:00
parent f409eb2c69
commit 0775c59e84
2 changed files with 9 additions and 17 deletions

View File

@@ -726,7 +726,9 @@ func (p DoltDatabaseProvider) databaseForRevision(ctx *sql.Context, revisionQual
dbCache, ok := sess.DatabaseCache(ctx, baseName)
if ok {
db, ok := dbCache.GetCachedRevisionDb(revisionQualifiedName)
if ok {
// The db cache is keyed by the revision qualified name, but the request name must also match for it to be a
// cache hit
if ok && db.RequestedName() == requestedName {
return db, true, nil
}
}

View File

@@ -174,24 +174,14 @@ func (d *DoltSession) lookupDbState(ctx *sql.Context, dbName string) (*branchSta
revisionQualifiedName = revisionDbName(baseName, rev)
}
// Try to get the session from the cache before going to the provider
var database SqlDatabase
if dbStateFound {
database, _ = dbState.databaseCache.GetCachedRevisionDb(revisionQualifiedName)
database, ok, err := d.provider.SessionDatabase(ctx, revisionQualifiedName)
if err != nil {
return nil, false, err
}
if !ok {
return nil, false, nil
}
if database == nil {
var err error
var ok bool
database, ok, err = d.provider.SessionDatabase(ctx, revisionQualifiedName)
if err != nil {
return nil, false, err
}
if !ok {
return nil, false, nil
}
}
// Add the initial state to the session for future reuse
if err := d.addDB(ctx, database); err != nil {
return nil, false, err