Skip to content

A credit can be added to a billing account that is being deleted #2010

Open

Description

@rohilsurana

CreateEntry checks that the billing account is live before it opens its transaction. The credit insert inside that transaction does not read the account again.

If the account delete commits between the check and the insert, a new live transaction is written for a deleted account. The delete only hides the transactions that exist when it runs, so this one is left outside the forfeit totals.

Proposed fix: inside CreateEntry's transaction, read the live customer row with FOR KEY SHARE before the balance check and the insert. It only has to conflict with the FOR UPDATE lock that the account delete takes. Return customer.ErrNotFound when the row is already soft deleted.

Context: found while reviewing the billing account delete change in #1999. It is listed there as a known gap.

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