Postgres pool, review round 1: nested transactions, account mail after commit

P-1: a transaction begun inside another one (a hook calling the Local API
without req) no longer queues behind its caller. An AsyncLocalStorage mark set
when a transaction begins lets the inner one through at once, without a
place, but never into the last connection (a second level may take that
one). If the mark is lost, a queue that has not moved for a second admits
its newest waiter. connectionReserve: false now admits everything, as
before. Measured on Postgres 17: 9, 12 and 30 such submissions finish
(before: stuck from 9).

P-2: Payload's "forgot password" and "verify your e-mail" through
mailAdapter() go out right after their transaction commits
(mail.accountMailAfterCommit, default on). With the relay hanging,
30 resets + 30 submissions finish in about 11 s instead of 43.5 s.

P-3: Postgres tests for the "not confirmed" file result after commit, a
caller's outer transaction rolled back or committed, the relay hanging,
and the nested rows; deployment.md has the measured table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 01:19:27 +01:00
co-authored by Claude Opus 5.5
parent 32bb542e8e
commit 4efadb21d5
18 changed files with 534 additions and 107 deletions
+7 -2
View File
@@ -425,7 +425,8 @@ and password switches the site to the client's server.
- The adapter reads the config on every send, so changing the mailbox in the panel works without a restart.
- **Time-outs** (since 1.17.0): 10 s to connect, 30 s for the server's greeting, 60 s of silence during the
dialogue (`SMTP_TIMEOUT_DEFAULTS`; nodemailer's own were 2 min and 10 min). A send inside a database transaction —
Payload's "forgot password" — holds a connection that long ([deployment.md](./deployment.md) §4.3a). Change them:
Payload's "forgot password" with `mail: { accountMailAfterCommit: false }` — holds a connection that long
([deployment.md](./deployment.md) §4.3a; by default that mail goes out after its transaction commits). Change them:
`mailAdapter({ smtp: { timeouts: { connectionMs, greetingMs, socketMs } } })` or `panelSmtpAdapter({ timeouts })`
(type `SmtpTimeouts`).
@@ -494,7 +495,11 @@ if (result.sent) {
Password reset and e-mail verification go through Payload's built-in mechanism (`config.email`). With
`mailAdapter()` wired they take the same transport as everything else; with the mail service they are sent as
account mail ("What a message is").
account mail ("What a message is"). Payload sends them inside the operation's database transaction; `mailAdapter()`
sends them right **after** it commits instead (still in the same request; nothing when it is rolled back), so a slow
mail server holds no database connection — `mail: { accountMailAfterCommit: false }` keeps them inside
([deployment.md](./deployment.md) §4.3a). An e-mail adapter of your own does the same by calling
`sendAccountMailAfterCommit(message, () => send(message))` first.
## Masking secrets in the panel (MaskedField)