mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-12 19:39:17 -05:00
go: doltdb: hooksdatabase.go: Execute commit hooks in parallel so that synchronous commit hooks do not serialize on each other.
This commit is contained in:
@@ -21,6 +21,8 @@ import (
|
||||
"github.com/dolthub/dolt/go/store/datas"
|
||||
"github.com/dolthub/dolt/go/store/hash"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
|
||||
"sync"
|
||||
)
|
||||
|
||||
type hooksDatabase struct {
|
||||
@@ -58,14 +60,21 @@ func (db hooksDatabase) PostCommitHooks() []CommitHook {
|
||||
|
||||
func (db hooksDatabase) ExecuteCommitHooks(ctx context.Context, ds datas.Dataset, onlyWS bool) {
|
||||
var err error
|
||||
var wg sync.WaitGroup
|
||||
for _, hook := range db.postCommitHooks {
|
||||
if !onlyWS || hook.ExecuteForWorkingSets() {
|
||||
err = hook.Execute(ctx, ds, db)
|
||||
if err != nil {
|
||||
hook.HandleError(ctx, err)
|
||||
}
|
||||
hook := hook
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
err = hook.Execute(ctx, ds, db)
|
||||
if err != nil {
|
||||
hook.HandleError(ctx, err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (db hooksDatabase) CommitWithWorkingSet(
|
||||
|
||||
Reference in New Issue
Block a user