Skip to content

bug: tasks - foreign key violated when stopping workspace #18776

Open
@hugodutka

Description

@hugodutka

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Sometimes, when you stop a task workspace, the operation fails with this error:

internal provisionerserver error: complete job: execute transaction: update workspace build ai tasks flag: pq: insert or update on table "workspace_builds" violates foreign key constraint "workspace_builds_ai_task_sidebar_app_id_fkey"
Image

Changing the workspace's version to an older version and then back again lets you work around the bug and stop the workspace.

Relevant Log Output

Expected Behavior

I'd expect to be able to stop the workspace without any problems.

Steps to Reproduce

I'm not sure how to reproduce this error. I've seen it happen when both the sidebar app and the coder_ai_task resource are created within a terraform module, that module is sourced from a git branch, and that branch gets updated between workspace start and stop. I don't know if these conditions are sufficient to reproduce the error.

Environment

  • Host OS: Linux
  • Coder version: 2.24.1

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue that require triage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions