t8y2/dbx · error · errXuguOperationCanceled

%w: %v

Error message

%w: %v

What it means

When the operation was canceled (context canceled / client abort) and the waiter also captured an error, the driver returns errXuguOperationCanceled ('xugu operation canceled' family) wrapped with the underlying error via %w. Callers can detect cancellation with errors.Is even though the message includes the cause.

Source

Thrown at agents/drivers/xugu/main.go:4326

	timedOut := s.activeTimedOut
	canceled := s.activeCanceled
	s.activeTimedOut = false
	s.activeCanceled = false
	s.activeCancelMu.Unlock()
	cancel()
	return xuguOperationResultError(timedOut, canceled, timeoutSecs, operationErr)
}

func xuguOperationResultError(timedOut, canceled bool, timeoutSecs int, operationErr error) error {
	if timedOut {
		if operationErr != nil {
			return fmt.Errorf("%w after %ds: %v", errXuguOperationTimeout, timeoutSecs, operationErr)
		}
		return fmt.Errorf("%w after %ds", errXuguOperationTimeout, timeoutSecs)
	}
	if canceled {
		if operationErr != nil {
			return fmt.Errorf("%w: %v", errXuguOperationCanceled, operationErr)
		}
		return errXuguOperationCanceled
	}
	return operationErr
}

func (s *server) cancelActiveQuery() {
	s.activeCancelMu.Lock()
	cancels := make([]context.CancelFunc, 0, len(s.activeRows)+1)
	if s.activeCancel != nil {
		if !s.activeTimedOut {
			s.activeCanceled = true
			// Explicit cancellation won the race. Disable the watchdog so a
			// slow driver return cannot relabel this operation as a timeout.
			if s.activeTimer != nil {
				s.activeTimer.Stop()
				s.activeTimer = nil
			}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Inspect the %v cause to identify which context or client canceled the work.
  2. Ensure application contexts have adequate deadlines before dispatching long operations.
  3. Avoid canceling clients/connections mid-operation; use server-side query limits instead.
  4. Detect deliberate cancellation with errors.Is(err, errXuguOperationCanceled) and handle it as a non-fatal path.

Example fix

// before
ctx, cancel := context.WithTimeout(ctx, 5*time.Second) // too short, cancels mid-query

// after
ctx, cancel := context.WithTimeout(ctx, 120*time.Second)
Defensive patterns

Strategy: type-guard

Validate before calling

select {
case <-ctx.Done():
    return fmt.Errorf("aborted before dispatch: %w", ctx.Err())
default:
    // safe to start the operation
}

Type guard

func IsCanceledErr(err error) bool { return errors.Is(err, errXuguOperationCanceled) || errors.Is(err, context.Canceled) }

Try / catch

if IsCanceledErr(err) {
    log.Info("operation canceled by caller")
    return nil // expected during shutdown
}

Prevention

When it happens

Trigger: The caller's context was canceled or the client closed/canceled the request while the operation was still running, and operationErr carries the driver-level cancellation error.

Common situations: HTTP request contexts canceled by the client disconnecting; ctx.WithTimeout on the application side firing first; shutting down a service mid-query; user-initiated aborts in tools built on the driver.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/908b06fa1b38b9a2. Report an issue: GitHub.