Skip to content

Commit

Permalink
/go/libraries/doltcore/sqle/dsess/autoincrement_tracker.go: add timeo…
Browse files Browse the repository at this point in the history
…ut to ai waitForInit
  • Loading branch information
coffeegoddd committed Jan 15, 2025
1 parent 68f99a4 commit abfafcb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions go/libraries/doltcore/sqle/dsess/autoincrement_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ package dsess

import (
"context"
"errors"
"io"
"math"
"strings"
"sync"
"time"

"github.com/dolthub/go-mysql-server/sql"
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
Expand Down Expand Up @@ -436,8 +438,19 @@ func (a *AutoIncrementTracker) AcquireTableLock(ctx *sql.Context, tableName stri
}

func (a *AutoIncrementTracker) waitForInit() error {
a.wg.Wait()
return a.initErr
done := make(chan struct{})

go func() {
defer close(done)
a.wg.Wait()
}()

select {
case <-done:
return a.initErr
case <-time.After(5 * time.Minute):
return errors.New("failed to initialize autoincrement tracker")
}
}

func (a *AutoIncrementTracker) runInitWithRootsAsync(ctx context.Context, roots ...doltdb.Rootish) {
Expand Down

0 comments on commit abfafcb

Please sign in to comment.