t8y2/dbx · info

xugu operation canceled

Error message

xugu operation canceled

What it means

errXuguOperationCanceled is a sentinel error returned by classifyRPCError when the Xugu driver reports the operation was canceled (e.g. context cancellation) rather than timed out. It is returned directly, or wrapped with the underlying operation error via %w, preserving errors.Is matching.

Source

Thrown at agents/drivers/xugu/protocol_error.go:20

import (
	"context"
	"database/sql"
	"database/sql/driver"
	"errors"
	"fmt"
	"io"
	"net"
	"regexp"
	"strconv"
	"strings"
)

var (
	errAgentSessionLimit     = errors.New("agent session limit reached")
	errAgentSessionNotFound  = errors.New("agent session not found")
	errXuguOperationTimeout  = errors.New("xugu operation timed out")
	errXuguOperationCanceled = errors.New("xugu operation canceled")

	// go-xugu-driver exposes server errors as plain strings rather than a typed
	// error. Match only the stable server error header and keep the complete
	// original message for diagnostics. A response can contain more than one
	// Xugu error; vendorCode intentionally records the first/top-level code.
	xuguServerErrorHeader = regexp.MustCompile(`(?im)^[\t ]*(?:error:[\t ]*)?\[[\t ]*E([0-9]{1,9})(?:[\t ]+L([0-9]+))?(?:[\t ]+C([0-9]+))?[\t ]*\]`)
	xuguQueryTimeout      = regexp.MustCompile(`(?i)^query timed out after [1-9][0-9]*s$`)
)

type rpcError struct {
	Code    int           `json:"code"`
	Message string        `json:"message"`
	Data    *rpcErrorData `json:"data,omitempty"`
}

type rpcErrorData struct {
	Category           string `json:"category"`
	Retryable          bool   `json:"retryable"`

View on GitHub (pinned to c0390bff16)

Solutions

  1. Identify what canceled the context (upstream deadline, user abort, shutdown) via the wrapped operationErr
  2. Only cancel contexts when the result is genuinely no longer needed
  3. For operations that must complete, use context.WithoutCancel or a detached context
  4. Distinguish cancellation from timeout in code with errors.Is(err, errXuguOperationCanceled)
  5. Re-issue the operation if cancellation was accidental

Example fix

// before
rows, err := conn.Query(ctx, q) // ctx canceled by HTTP client disconnect
// after
rows, err := conn.Query(context.WithoutCancel(ctx), q)
if errors.Is(err, errXuguOperationCanceled) { /* graceful cleanup */ }
Defensive patterns

Strategy: try-catch

Type guard

func IsXuguOperationCanceled(err error) bool {
    return errors.Is(err, errXuguOperationCanceled)
}

Try / catch

rows, err := conn.Query(ctx, q)
if errors.Is(err, errXuguOperationCanceled) {
    // context was canceled: clean up quietly, do not retry with the same ctx
    return ctx.Err()
}

Prevention

When it happens

Trigger: classifyRPCError sets canceled and main.go:4326-4328 returns errXuguOperationCanceled (optionally wrapped with the underlying error) when the driver signals cancellation — typically the caller's context was canceled/closed mid-operation.

Common situations: User cancels a query in the UI, HTTP request context is canceled while a query runs, application shutdown closes the context, an upstream deadline fires before the Xugu timeout.

Related errors


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