Skip to content

Discarded job continues execution (context not cancelled) #1135

Description

@NanoBjorn

Following #1105 (comment), I think this is worth a separate issue.

As I already described in #1105, there is a theoretically possible situation when actually running and healthy job is marked as discarded. And while it is marked as discarded worker might still continue executing it because it did not receive any notification about job being discarded. It creates a situation which might violate unique_key invariant, as happened in the linked issue — discarded job goroutine is actually running and new job can be potentially scheduled, not violating unique key constraint as from db point of view this is correct

CREATE UNIQUE INDEX IF NOT EXISTS river_job_unique_idx ON /* TEMPLATE: schema */river_job (unique_key)
WHERE unique_key IS NOT NULL
AND unique_states IS NOT NULL
AND /* TEMPLATE: schema */river_job_state_in_bitmask(unique_states, state);

I guess it either could be done through pg_notify or polling job row every few seconds, and the second one is not great for db. I don't know what are other good options, so creating this issue to discuss

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions