Merge claude/postgres-mail-deadlock: Postgres keeps connections free of transactions; form and account mail go out after the commit
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -132,6 +132,39 @@ once there are more than 20.
|
||||
Not a switch for a live site: it would start visitors' histories and the running 2FA counts again.
|
||||
- `EnvRule.aliases` for `assertEnv`: older names of a variable, read when the main one is missing.
|
||||
|
||||
### Fixed — Postgres: many requests at once no longer stop the site (draft; release decided by the owner)
|
||||
- **Ten or more form submissions at the same moment, or ten "forgot password" requests, stopped the whole site on
|
||||
Postgres** — every request, also pages that only read, waited for good (older than 1.17.0; MongoDB sites were not
|
||||
affected). Each transaction holds a pool connection, and code inside it that runs without its `req` (Payload's own
|
||||
"forgot password", the e-mail adapter reading Site integrations and writing the send status, `payload.kv`) needs a
|
||||
second one; the default pool has 10. Measured on Postgres 17: 12 submissions or 12 resets at once never finished;
|
||||
now 30 of each, also against an SMTP server that never answers, finish while an ordinary request answers at once.
|
||||
- **`connectionReserve`** (new plugin option, default on): a fifth of the pool, at least 2, stays free of
|
||||
transactions; at most `pool size − reserve` transactions are open at once and the next one waits. A transaction
|
||||
begun inside another one (a project hook that calls the Local API without `req`) takes no place and goes at once,
|
||||
but never takes the last connection — 9, 12 and 30 such submissions at once finish (before: 12 stopped the site).
|
||||
`false` = as before. Building blocks `reserveConnections`, `watchTransactions`, `afterCommit`,
|
||||
`inWatchedTransaction`, `transactionsBusy`, `transactionWatchState`, `poolSize`, `defaultConnectionReserve`,
|
||||
`RESERVE_ESCAPE_MS` ([deployment.md](./deployment.md) §4.3a, with the measured table).
|
||||
- **Payload's "forgot password" and "verify your e-mail" go out after their transaction commits** when sent through
|
||||
`mailAdapter()` (`mail.accountMailAfterCommit`, default on; same request, nothing sent on a rollback). The message is
|
||||
matched to its request by its token (Payload's `generateEmailSubject` is wrapped; a project's own one is kept). With the mail
|
||||
service hanging, 30 resets and 30 submissions at once finish in about one send budget (11 s) instead of 43.5 s.
|
||||
Building blocks `withAccountMailAfterCommit`, `sendAccountMailAfterCommit`, `holdAccountMail`,
|
||||
`releaseAccountMail`.
|
||||
- **Form e-mails go out after the submission's transaction commits** — same request, same answer to the visitor
|
||||
(a file that could not be sent is still reported). A submission rolled back by a later hook now sends nothing; a
|
||||
send that fails after the commit leaves the submission stored (as a failed e-mail always did). Sites without
|
||||
transactions (MongoDB without a replica set, SQLite) send at once, as before. The old way:
|
||||
`forms: { emailsInTransaction: true }`. Building blocks `sendAfterCommit`, `sendFormEmails`
|
||||
([forms.md](./forms.md) "When e-mails go out").
|
||||
- **The panel's send status** (`recordIntegrationStatus`): many sends failing at once write it once; while the pool
|
||||
is busy the write is not waited for.
|
||||
- **SMTP time-outs**: 10 s to connect (was nodemailer's 2 min), 30 s for the greeting, 60 s of silence (was 10 min);
|
||||
`mailAdapter({ smtp: { timeouts } })` / `panelSmtpAdapter({ timeouts })`, `SMTP_TIMEOUT_DEFAULTS`, `SmtpTimeouts`.
|
||||
- Not covered: an e-mail adapter of your own (not `mailAdapter()`) still gets Payload's account mail inside the
|
||||
transaction unless it calls `sendAccountMailAfterCommit` first.
|
||||
|
||||
### Deprecated
|
||||
- **Microsoft Graph as an e-mail transport** — `graphAdapter`, `GraphAdapterArgs`, `mailAdapter({ graph })`,
|
||||
`iaplEnvRules({ emailGraph })` and the four `GRAPH_*` variables. Nothing new is built on it; it gets fixes only and
|
||||
|
||||
Reference in New Issue
Block a user