Skip to content

Cycle Version field is unused, so concurrent cycle edits lost-update #383

Description

@cavidelizade

Summary

Cycle.Version exists to guard against lost updates but is never read, so concurrent cycle edits silently clobber each other.

Where

model.Cycle.Version is set to 1 on create (internal/service/cycle.go) and never referenced again. CycleStore.Update is a full-row Save with no WHERE version = ? and no increment. CycleService.Update and CompleteCycle both load the cycle, mutate the struct, and full-row Save.

Impact

An admin editing a cycle's dates while CompleteCycle writes the progress snapshot (or two concurrent edits) lost-update each other. The version column that exists precisely to prevent this is inert. (webhook.Version is similarly a static string, not a concurrency token.)

Suggested fix

Either enforce optimistic concurrency using the version column (compare-and-increment in the update WHERE, return a conflict on mismatch), or switch these writes to UpdateFields with a changed-columns map like the issue PATCH path already does.

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