{"record":{"id":"76d29af4d7fb8693","repo":"cockroachdb/cockroach","slug":"multiple-schedules-found-for-id","errorCode":null,"errorMessage":"Multiple schedules found for ID.","messagePattern":"Multiple schedules found for ID\\.","errorType":"http","errorClass":"RequestError","httpStatus":500,"severity":"critical","filePath":"pkg/ui/workspaces/cluster-ui/src/api/schedulesApi.ts","lineNumber":132,"sourceCode":"                 state, recurrence, jobsrunning, owner,\n                 created, jsonb_pretty(command) as command\n          FROM schedules\n          WHERE ID = $1::int64\n        `,\n        arguments: [id.toString()],\n      },\n    ],\n    execute: true,\n  };\n  return executeInternalSql<ScheduleColumns>(request).then(result => {\n    const txnResults = result.execution.txn_results;\n    if (txnResults.length === 0 || !txnResults[0].rows) {\n      // No data.\n      throw new RequestError(400, \"No schedule found with this ID.\");\n    }\n\n    if (txnResults[0].rows.length > 1) {\n      throw new RequestError(500, \"Multiple schedules found for ID.\");\n    }\n    const row = txnResults[0].rows[0];\n    return {\n      id: Long.fromString(row.id),\n      label: row.label,\n      status: row.schedule_status,\n      nextRun: row.next_run ? moment.utc(row.next_run) : null,\n      state: row.state,\n      recurrence: row.recurrence,\n      jobsRunning: row.jobsrunning,\n      owner: row.owner,\n      created: moment.utc(row.created),\n      command: row.command,\n    };\n  });\n}\n","sourceCodeStart":114,"sourceCodeEnd":149,"githubUrl":"https://github.com/cockroachdb/cockroach/blob/8812064a015d2faf99d3fc7e15880f94042954b0/pkg/ui/workspaces/cluster-ui/src/api/schedulesApi.ts#L114-L149","documentation":"Same system.schedules point lookup: if more than one row comes back for a single id, schedulesApi throws RequestError(500, 'Multiple schedules found for ID.'). id is the primary key of system.schedules, so multiple rows violate a table invariant — the 500 (vs the 400 for not-found) marks it as a server-side integrity problem, not bad input.","triggerScenarios":"SELECT ... WHERE ID = $1 returning >1 row, which requires duplicate primary-key values in system.schedules — realistically only from table corruption or a patched/custom query that lost the equality predicate.","commonSituations":"Essentially never in healthy clusters; appears after manual fiddling with system.schedules rows, disk-level corruption, or a modified schedulesApi query (e.g. accidental LIKE or missing WHERE).","solutions":["Check for duplicates: SELECT id, count(*) FROM system.schedules GROUP BY id HAVING count(*) > 1","If duplicates exist, treat as cluster corruption: capture details and engage support / file an issue rather than deleting rows blindly","If using a patched console, diff schedulesApi.ts to confirm the WHERE ID = $1::int64 predicate and int64 cast are intact"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isRequestError = (\n  e: unknown,\n  status?: number,\n): e is RequestError =>\n  e instanceof RequestError && (status === undefined || e.status === status);","tryCatchPattern":"try {\n  const schedule = await getSchedule(id);\n} catch (e) {\n  if (isRequestError(e, 500)) {\n    // Invariant violation on a PK table: report, do not retry blindly\n    reportError(e);\n    return <Alert type='error' title='Schedule data integrity problem' />;\n  }\n  throw e;\n}","preventionTips":["Never modify system.schedules rows by hand","Keep schedulesApi.ts's WHERE ID = $1::int64 predicate intact when patching the console","Alert on this error — a single occurrence implies corruption worth investigating"],"tags":["cluster-ui","schedules","data-integrity","system-tables","typescript"],"backgroundTag":null,"analyzedSha":"8812064a015d2faf99d3fc7e15880f94042954b0","analyzedAt":"2026-08-15T16:34:17.351Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}