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

  1. Read the wrapped cause (%w) for the concrete SQLite error (locked, disk I/O, constraint).
  2. Ensure only one Wave server instance is running and no other process holds the DB lock.
  3. Check free disk space and write permissions on the Wave data directory.
  4. 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

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


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/47cd9911c8455ac6. Report an issue: GitHub.