Tenant count limits can be passed by parallel writes #498

Closed
opened 2026-11-20 16:18:42 +00:00 by jcoffey-dev · 1 comment
Owner

Parallel writes can push a tenant past its count limits (MT-17).

The check counts the tenant's objects and the save happens afterwards, with nothing stopping another write in between. 16 account creates sent at the same moment by four tenant administrators, into a tenant limited to 8 accounts with 4 left, once ended at 9. Every count limit has the same gap (accounts, groups, domains, mailing lists, roles, OAuth clients, DKIM keys, DNS servers, directories, ACME providers), and so does directory sign-in, which creates accounts too.

Two smaller gaps in the same check:

  • Only new objects are counted. One whose tenant changes on an update (for example a role a server administrator moves into a tenant) skips the limit.
  • A domain's DKIM keys count only when the domain is created. Adding algorithms to an existing domain, or switching it to automatic DKIM, makes the DKIM task generate keys that are never counted against maxDkimKeys.

Fix: one per-tenant write lock, shared with the disk-quota check, held from the tenancy checks to the save; count objects joining a tenant on update; count the keys an update adds.

Part of the inbuxa/inbuxa-admin#257 remediation (Refs inbuxa/inbuxa-admin#257).

Parallel writes can push a tenant past its count limits (MT-17). The check counts the tenant's objects and the save happens afterwards, with nothing stopping another write in between. 16 account creates sent at the same moment by four tenant administrators, into a tenant limited to 8 accounts with 4 left, once ended at 9. Every count limit has the same gap (accounts, groups, domains, mailing lists, roles, OAuth clients, DKIM keys, DNS servers, directories, ACME providers), and so does directory sign-in, which creates accounts too. Two smaller gaps in the same check: - Only new objects are counted. One whose tenant changes on an update (for example a role a server administrator moves into a tenant) skips the limit. - A domain's DKIM keys count only when the domain is created. Adding algorithms to an existing domain, or switching it to automatic DKIM, makes the DKIM task generate keys that are never counted against maxDkimKeys. Fix: one per-tenant write lock, shared with the disk-quota check, held from the tenancy checks to the save; count objects joining a tenant on update; count the keys an update adds. Part of the inbuxa/inbuxa-admin#257 remediation (Refs inbuxa/inbuxa-admin#257).
jcoffey-dev added this to the 27.1 milestone 2026-11-20 16:18:42 +00:00
jcoffey-dev added the bug
priority
p2
labels 2026-11-20 16:18:42 +00:00
jcoffey-dev self-assigned this 2026-11-20 16:18:42 +00:00
Author
Owner

Fixed in #501 (7611b828): count limits are checked and saved under the tenant's write lock, objects joining a tenant on an update count, and DKIM keys an update adds count against maxDkimKeys. In the next 27.1 release candidate.

Fixed in #501 (7611b828): count limits are checked and saved under the tenant's write lock, objects joining a tenant on an update count, and DKIM keys an update adds count against maxDkimKeys. In the next 27.1 release candidate.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: inbuxa/inbuxa-server#498