{"record":{"id":"1ddfbfc3ee608128","repo":"gastownhall/beads","slug":"dolt-stats-gc-w-1ddfbf","errorCode":null,"errorMessage":"dolt_stats_gc: %w","messagePattern":"dolt_stats_gc: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/storage/dbproxy/server/doltserver.go","lineNumber":407,"sourceCode":"\t\treturn nil\n\t}\n\tdb, err := sql.Open(\"mysql\", s.DSN(ctx, s.database, \"root\", \"\"))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"open gc connection: %w\", err)\n\t}\n\tdefer func() { retErr = errors.Join(retErr, db.Close()) }()\n\n\tconn, err := db.Conn(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"acquire gc connection: %w\", err)\n\t}\n\tdefer func() { retErr = errors.Join(retErr, conn.Close()) }()\n\n\tif err := versioncontrolops.DoltGC(ctx, conn); err != nil {\n\t\tretErr = errors.Join(retErr, err)\n\t}\n\tif _, err := conn.ExecContext(ctx, \"CALL DOLT_STATS_GC()\"); err != nil {\n\t\tretErr = errors.Join(retErr, fmt.Errorf(\"dolt_stats_gc: %w\", err))\n\t}\n\treturn retErr\n}\n\nfunc (s *DoltServer) Running(_ context.Context) bool {\n\tif s.egCtx == nil {\n\t\treturn false\n\t}\n\treturn s.egCtx.Err() == nil\n}\n\nfunc (s *DoltServer) Dial(ctx context.Context) (net.Conn, error) {\n\tnetwork, addr := \"tcp\", net.JoinHostPort(s.config.Host(), strconv.Itoa(s.config.Port()))\n\tif sock := s.config.Socket(); sock != \"\" {\n\t\tnetwork, addr = \"unix\", sock\n\t}\n\tvar d net.Dialer\n\tconn, err := d.DialContext(ctx, network, addr)","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/server/doltserver.go#L389-L425","documentation":"After DoltGC succeeds, runShutdownGC executes CALL DOLT_STATS_GC() on the same connection to garbage-collect Dolt statistics tables. This error wraps the SQL failure from that stored-procedure call.","triggerScenarios":"Stop triggers shutdown GC; DOLT_STATS_GC() fails because the dolt_stats schema/procedure is missing (older Dolt server version), the stats subsystem is disabled, the connection died mid-call, or the context was cancelled.","commonSituations":"Running against an external/older dolt sql-server that predates DOLT_STATS_GC; stats tables corrupted; shutdown timeout elapsing while the procedure runs on a large database.","solutions":["Upgrade the Dolt server binary to a version that provides DOLT_STATS_GC()","Verify with `CALL DOLT_STATS_GC();` in a dolt sql shell against the same database","Increase shutdown timeout so the procedure can complete on large databases","If the joined Stop error contains only dolt_stats_gc and data is intact, treat as non-fatal but file/upgrade — GC hygiene is degraded"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// detect capability before relying on stats GC\nconn.QueryContext(ctx, \"SELECT 1 FROM information_schema.routines WHERE routine_name='DOLT_STATS_GC'\") // if empty, server is too old","typeGuard":null,"tryCatchPattern":"if err := server.Stop(ctx); err != nil {\n    if strings.Contains(err.Error(), \"dolt_stats_gc\") {\n        log.Warn(\"stats GC failed (old Dolt version?); core GC result unaffected\", \"err\", err)\n        err = nil\n    }\n    return err\n}","preventionTips":["Keep the dolt server binary at or above the version that ships DOLT_STATS_GC","Smoke-test `CALL DOLT_STATS_GC();` after every server upgrade","Use a shutdown timeout proportional to database size"],"tags":["go","mysql","stored-procedure","dolt","gc"],"backgroundTag":"stored-procall-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}