Skip to content

Estimate creation is not atomic #384

Description

@cavidelizade

Summary

Creating an estimate does three separate writes with no transaction, so a partial failure leaves a broken estimate or two "last used" estimates.

Where

internal/service/estimate.go Create: es.Create (the estimate row), es.ReplacePoints, and es.ClearLastUsedExcept are three independent DB calls with no wrapping transaction.

Impact

If ReplacePoints fails, an estimate persists with zero points. If lastUsed is true and ClearLastUsedExcept fails after the estimate was inserted with LastUsed: true, the project ends up with two last_used estimates.

Suggested fix

Wrap the estimate insert, point replacement, and last-used clearing in one transaction.

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