Hold tenant count limits under the tenant's write lock (#498) #501

Merged
jcoffey-dev merged 1 commits from fix/tenant-count-lock into main 2026-11-20 17:03:38 +00:00
Owner

The count limits (MT-17) were checked by counting the tenant's objects
and then saving, with nothing to stop another write in between. 16
account creates at once from four tenant administrators, with 4 left
under maxAccounts 8, ended at 9 in 2 of 15 live rounds. Every count
limit had the gap, and so did directory sign-in.

  • The disk-quota lock from #497 becomes the tenant's write lock, in
    common (Server::lock_tenant_writes / unlock_tenant_writes), one per
    tenant for counts and disk space alike, so a write never holds two.
    It keeps the old key so nodes on either version share it during a
    rolling upgrade. writes::locked_tenant names the tenant to lock: a
    counted object joining it, a domain adding DKIM keys, or a write
    that grows its allocated disk space. x:*/set (JMAP and SCIM), a
    deleted account's restore, and directory sign-in's user and group
    creation hold it from the tenancy checks to the save.
  • An object joining a tenant on an update (its tenant changes) now
    counts against the limit like a new one; before, only creates did.
    A domain's move is still counted by its plan (MT-8).
  • An update that adds DKIM algorithms to a domain, or switches it to
    automatic DKIM, counts the keys the DKIM task will generate against
    maxDkimKeys (MT-9); before, only a new domain's keys counted.
    Rotation, which replaces a key, isn't counted again.

Checked live against a debug build: 15 rounds of 16 parallel creates
into a tenant with 4 of 8 left, every round 8/8 (main's build passed the
limit in 2 of 15). tenant_tests gains the DKIM-update and moved-role
cases; tenant, undelete, scim and legal_hold suites pass.

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

Refs #498.

The count limits (MT-17) were checked by counting the tenant's objects and then saving, with nothing to stop another write in between. 16 account creates at once from four tenant administrators, with 4 left under maxAccounts 8, ended at 9 in 2 of 15 live rounds. Every count limit had the gap, and so did directory sign-in. - The disk-quota lock from #497 becomes the tenant's write lock, in common (Server::lock_tenant_writes / unlock_tenant_writes), one per tenant for counts and disk space alike, so a write never holds two. It keeps the old key so nodes on either version share it during a rolling upgrade. writes::locked_tenant names the tenant to lock: a counted object joining it, a domain adding DKIM keys, or a write that grows its allocated disk space. x:*/set (JMAP and SCIM), a deleted account's restore, and directory sign-in's user and group creation hold it from the tenancy checks to the save. - An object joining a tenant on an update (its tenant changes) now counts against the limit like a new one; before, only creates did. A domain's move is still counted by its plan (MT-8). - An update that adds DKIM algorithms to a domain, or switches it to automatic DKIM, counts the keys the DKIM task will generate against maxDkimKeys (MT-9); before, only a new domain's keys counted. Rotation, which replaces a key, isn't counted again. Checked live against a debug build: 15 rounds of 16 parallel creates into a tenant with 4 of 8 left, every round 8/8 (main's build passed the limit in 2 of 15). tenant_tests gains the DKIM-update and moved-role cases; tenant, undelete, scim and legal_hold suites pass. Part of the inbuxa/inbuxa-admin#257 remediation (Refs inbuxa/inbuxa-admin#257). Refs #498.
jcoffey-dev added this to the 27.1 milestone 2026-11-20 16:47:35 +00:00
jcoffey-dev added 1 commit 2026-11-20 16:47:35 +00:00
Hold tenant count limits under the tenant's write lock (#498)
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 15m5s
8f8d6965d5
The count limits (MT-17) were checked by counting the tenant's objects
and then saving, with nothing to stop another write in between. 16
account creates at once from four tenant administrators, with 4 left
under maxAccounts 8, ended at 9 in 2 of 15 live rounds. Every count
limit had the gap, and so did directory sign-in.

- The disk-quota lock from #497 becomes the tenant's write lock, in
  common (Server::lock_tenant_writes / unlock_tenant_writes), one per
  tenant for counts and disk space alike, so a write never holds two.
  It keeps the old key so nodes on either version share it during a
  rolling upgrade. writes::locked_tenant names the tenant to lock: a
  counted object joining it, a domain adding DKIM keys, or a write
  that grows its allocated disk space. x:*/set (JMAP and SCIM), a
  deleted account's restore, and directory sign-in's user and group
  creation hold it from the tenancy checks to the save.
- An object joining a tenant on an update (its tenant changes) now
  counts against the limit like a new one; before, only creates did.
  A domain's move is still counted by its plan (MT-8).
- An update that adds DKIM algorithms to a domain, or switches it to
  automatic DKIM, counts the keys the DKIM task will generate against
  maxDkimKeys (MT-9); before, only a new domain's keys counted.
  Rotation, which replaces a key, isn't counted again.

Checked live against a debug build: 15 rounds of 16 parallel creates
into a tenant with 4 of 8 left, every round 8/8 (main's build passed the
limit in 2 of 15). tenant_tests gains the DKIM-update and moved-role
cases; tenant, undelete, scim and legal_hold suites pass.

Part of the inbuxa/inbuxa-admin#257 remediation (Refs
inbuxa/inbuxa-admin#257).
jcoffey-dev merged commit 7611b8282e into main 2026-11-20 17:03:38 +00:00
jcoffey-dev deleted branch fix/tenant-count-lock 2026-11-20 17:03:39 +00:00
Sign in to join this conversation.