You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sub-account create can disable an address under a concurrent winner's grant #72
When creating a sub-account fails after the address was registered or reinstated, the handler disables the address again so it is not left accepting mail without a grant. #71 skips that rollback when the store returns ErrAlreadyExists, so a concurrent create that won the race keeps its address. The loser does not always see ErrAlreadyExists, though: createGrant checks the owner's limit before the insert (internal/apiauth/store.go).
The owner is one below max_sub_accounts. Requests A and B create the same agent concurrently.
A registers the address (created = true). B sees it existing and accepting, so B has nothing to roll back.
B takes the advisory lock first, inserts and commits. The owner is now at the limit.
A's createGrant returns ErrLimitExceeded. A disables the address, and B's live grant now points at an address that no longer accepts mail.
Any other failure on A's side after B has committed (a dropped connection, a cancelled request) has the same effect.
Suggested fix
Do not infer the outcome from the error type. Before disabling, ask the store whether an active grant exists for the sub-address, and skip the disable if one does. Apply the same check in runAPIKeyCreate (cmd/fmsg-webapi/apikey_cli.go), which has the same rollback.
A test that runs the two creates in that order at one below the limit would pin it.
Activity