wavetermdev/waveterm · error
failed to create job in database: %w
Error message
failed to create job in database: %w
What it means
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.
Source
Thrown at pkg/jobcontroller/jobcontroller.go:667
job := &waveobj.Job{
OID: jobId,
Connection: params.ConnName,
JobKind: params.JobKind,
Cmd: params.Cmd,
CmdArgs: params.Args,
CmdEnv: params.Env,
CmdTermSize: *params.TermSize,
JobAuthToken: jobAuthToken,
JobManagerStatus: JobManagerStatus_Init,
AttachedBlockId: params.BlockId,
WaveVersion: wavebase.WaveVersion,
Meta: make(waveobj.MetaMapType),
}
err = wstore.DBInsert(ctx, job)
if err != nil {
return "", fmt.Errorf("failed to create job in database: %w", err)
}
if params.BlockId != "" {
// AttachJobToBlock will send status
err = AttachJobToBlock(ctx, jobId, params.BlockId)
if err != nil {
return "", fmt.Errorf("failed to attach job to block: %w", err)
}
}
bareRpc := wshclient.GetBareRpcClient()
broker := bareRpc.StreamBroker
readerRouteId := wshclient.GetBareRpcClientRouteId()
writerRouteId := wshutil.MakeJobRouteId(jobId)
reader, streamMeta := broker.CreateStreamReader(readerRouteId, writerRouteId, DefaultStreamRwnd)
jobStreamIds.Set(jobId, streamMeta.Id)
fileOpts := wshrpc.FileOpts{
MaxSize: 10 * 1024 * 1024,
Circular: true,View on GitHub (pinned to a4447c1563)
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).
Defensive patterns
Strategy: retry
Try / catch
jobId, err := jobcontroller.StartJob(ctx, params)
if err != nil && strings.Contains(err.Error(), "failed to create job in database") {
// check disk space / DB lock, then retry once
jobId, err = jobcontroller.StartJob(ctx, params)
} Prevention
- 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.
When it happens
Trigger: DBInsert fails due to SQLite errors: database file locked, disk full, schema migration mismatch, or constraint violation on the job OID.
Common situations: Multiple Wave processes contending for the same database, read-only or full disk, corrupted waveterm local DB, partially upgraded schema after a version change.
Related errors
- opening db: %w
- error getting mainserver: %w
- error getting client: %v
- error getting block: %w
- error getting block: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/47cd9911c8455ac6.
Report an issue: GitHub.