gastownhall/beads · warning

%s close timed out after %v

Error message

%s close timed out after %v

What it means

closeWithDeadline guards database Close calls that can hang. If the close does not finish within CloseTimeout, the library gives up waiting and returns '%s close timed out after %v' so callers are not blocked forever. The close may still complete later in the background.

Source

Thrown at internal/storage/doltutil/close.go:34

func CloseWithTimeout(name string, closeFn func() error) error {
	timer := time.NewTimer(CloseTimeout)
	defer timer.Stop()

	return closeWithDeadline(name, closeFn, timer.C)
}

func closeWithDeadline(name string, closeFn func() error, deadline <-chan time.Time) error {
	done := make(chan error, 1)
	go func() {
		done <- closeFn()
	}()

	select {
	case err := <-done:
		return err
	case <-deadline:
		// Close is hanging - log and continue rather than blocking forever
		return fmt.Errorf("%s close timed out after %v", name, CloseTimeout)
	}
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Wait past CloseTimeout and verify the process/database eventually released resources.
  2. Find and cancel in-flight queries/transactions before closing.
  3. Kill a hung embedded Dolt process if it never finishes closing.
  4. Increase CloseTimeout if legitimate large closes need more time.

Example fix

// before
defer store.Close() // may hang
// after
if err := doltutil.CloseWithTimeout(store, 5*time.Second); err != nil {
    log.Printf("close problem (continuing): %v", err)
}
Defensive patterns

Strategy: fallback

Validate before calling

// ensure no in-flight work before closing:
// wg.Wait() on outstanding queries/transactions

Try / catch

if err := doltutil.CloseWithTimeout(store, 5*time.Second); err != nil {
    log.Printf("close timed out, continuing: %v", err) // non-fatal
}

Prevention

When it happens

Trigger: Calling CloseWithTimeout (or Close paths using closeWithDeadline) on a Dolt store whose underlying close blocks — e.g. in-flight queries, hung Dolt engine process, or an open transaction blocking shutdown.

Common situations: Long-running query still executing at shutdown; Dolt subprocess wedged; many open connections draining slowly; disk I/O stall.

Understand the failure class

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/7fda9329d73b1520. Report an issue: GitHub.