go: sqle: auto_gc: Responding to PR feedback. Comments and cleanup.

This commit is contained in:
Aaron Son
2025-02-13 17:24:03 -08:00
parent 10dfcec18f
commit 2a47d402b2
3 changed files with 20 additions and 13 deletions

View File

@@ -115,6 +115,13 @@ func NewSqlEngine(
return nil, err
}
// Make a copy of the databases. |all| is going to be provided
// as the set of all initial databases to dsqle
// DatabaseProvider. |dbs| is only the databases that came
// from MultiRepoEnv, and they are all real databases based on
// DoltDB instances. |all| is going to include some extension,
// informational databases like |dolt_cluster| sometimes,
// depending on config.
all := make([]dsess.SqlDatabase, len(dbs))
copy(all, dbs)

View File

@@ -1919,16 +1919,12 @@ func (ddb *DoltDB) IsTableFileStore() bool {
func (ddb *DoltDB) ChunkJournal() *nbs.ChunkJournal {
cs := datas.ChunkStoreFromDatabase(ddb.db)
var store *nbs.NomsBlockStore
generationalNBS, ok := cs.(*nbs.GenerationalNBS)
if ok {
store = generationalNBS.NewGen().(*nbs.NomsBlockStore)
} else {
store = cs.(*nbs.NomsBlockStore)
if generationalNBS, ok := cs.(*nbs.GenerationalNBS); ok {
cs = generationalNBS.NewGen()
}
if store != nil {
return store.ChunkJournal()
if nbsStore, ok := cs.(*nbs.NomsBlockStore); ok {
return nbsStore.ChunkJournal()
} else {
return nil
}

View File

@@ -154,13 +154,17 @@ func (c *AutoGCController) newCommitHook(name string) doltdb.CommitHook {
type autoGCCommitHook struct {
c *AutoGCController
name string
// Always non-nil, if this channel delivers this channel
// delivers when no GC is currently running.
// When |done| is closed, there is no GC currently running or
// pending for this database. If it is open, then there is a
// pending request for GC or a GC is currently running. Once
// |done| is closed, we can check for auto GC conditions on
// the database to see if we should request a new GC.
done chan struct{}
// It simplifies the logic and efficiency of the
// implementation a bit to have a
// we can send. It becomes our new |done| channel on a
// successful send.
// implementation a bit to have an already allocated // in the commit hook.
channel
// we can try to send, which will become our new |done|
// channel once we send it successfully.
next chan struct{}
// |done| and |next| are mutable and |Execute| can be called
// concurrently. We protect them with |mu|.