{"record":{"id":"47cd9911c8455ac6","repo":"wavetermdev/waveterm","slug":"failed-to-create-job-in-database-w","errorCode":null,"errorMessage":"failed to create job in database: %w","messagePattern":"failed to create job in database: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/jobcontroller/jobcontroller.go","lineNumber":667,"sourceCode":"\n\tjob := &waveobj.Job{\n\t\tOID:              jobId,\n\t\tConnection:       params.ConnName,\n\t\tJobKind:          params.JobKind,\n\t\tCmd:              params.Cmd,\n\t\tCmdArgs:          params.Args,\n\t\tCmdEnv:           params.Env,\n\t\tCmdTermSize:      *params.TermSize,\n\t\tJobAuthToken:     jobAuthToken,\n\t\tJobManagerStatus: JobManagerStatus_Init,\n\t\tAttachedBlockId:  params.BlockId,\n\t\tWaveVersion:      wavebase.WaveVersion,\n\t\tMeta:             make(waveobj.MetaMapType),\n\t}\n\n\terr = wstore.DBInsert(ctx, job)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create job in database: %w\", err)\n\t}\n\tif params.BlockId != \"\" {\n\t\t// AttachJobToBlock will send status\n\t\terr = AttachJobToBlock(ctx, jobId, params.BlockId)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to attach job to block: %w\", err)\n\t\t}\n\t}\n\tbareRpc := wshclient.GetBareRpcClient()\n\tbroker := bareRpc.StreamBroker\n\treaderRouteId := wshclient.GetBareRpcClientRouteId()\n\twriterRouteId := wshutil.MakeJobRouteId(jobId)\n\treader, streamMeta := broker.CreateStreamReader(readerRouteId, writerRouteId, DefaultStreamRwnd)\n\tjobStreamIds.Set(jobId, streamMeta.Id)\n\n\tfileOpts := wshrpc.FileOpts{\n\t\tMaxSize:  10 * 1024 * 1024,\n\t\tCircular: true,","sourceCodeStart":649,"sourceCodeEnd":685,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/jobcontroller/jobcontroller.go#L649-L685","documentation":"After building the waveobj.Job record, StartJob persists it with wstore.DBInsert; a database failure is wrapped with this message. The wstore is the local SQLite-backed object store, so this reflects local storage trouble, not the remote connection.","triggerScenarios":"DBInsert fails due to SQLite errors: database file locked, disk full, schema migration mismatch, or constraint violation on the job OID.","commonSituations":"Multiple Wave processes contending for the same database, read-only or full disk, corrupted waveterm local DB, partially upgraded schema after a version change.","solutions":["Read the wrapped cause (%w) for the concrete SQLite error (locked, disk I/O, constraint).","Ensure only one Wave server instance is running and no other process holds the DB lock.","Check free disk space and write permissions on the Wave data directory.","Back up and repair/reset the local database if it is corrupted (last resort)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"jobId, err := jobcontroller.StartJob(ctx, params)\nif err != nil && strings.Contains(err.Error(), \"failed to create job in database\") {\n    // check disk space / DB lock, then retry once\n    jobId, err = jobcontroller.StartJob(ctx, params)\n}","preventionTips":["Run only one Wave server instance against a given data directory.","Monitor disk space for the Wave data directory (SQLite needs headroom).","Back up the local DB before upgrading Wave Terminal versions."],"tags":["database","sqlite","storage"],"backgroundTag":"database-insert-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}