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:
@@ -1246,6 +1246,10 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
|
||||
| Account e-mails through the mail service: at most 5 to one address and 10 asked for by one visitor an hour | `mail: { relay: { accountMail: false } }` | `accountMail: { perAddress, perVisitor, windowMinutes }` |
|
||||
| Every message says what it is (form notification, form confirmation, account, test, system) | — (other transports ignore the mark) | `withMailKind`, `runWithMailKind`, `expectMailTo`, `mail.relay.kind`, `buildFormMailKindHook` |
|
||||
| Microsoft Graph as transport: deprecated, one warning per start, removed in 2.0 | `mail: { graphDeprecationWarning: false }` (the warning only) | move off it: email.md "Moving off Microsoft Graph" |
|
||||
| Postgres: a fifth of the pool (at least 2) stays free of transactions — at most `pool size − reserve` open at once, the next waits; a transaction begun inside another one (a hook without `req`) takes no place and goes at once, but never the last connection. Without it ten form submissions or "forgot password" requests at once stopped the site | `connectionReserve: false` | `connectionReserve: <number>`; `reserveConnections(payload, n)` in your own `onInit` (without `iapl()`); `watchTransactions`, `afterCommit`, `inWatchedTransaction`, `transactionsBusy`, `transactionWatchState` (`{ active, nested, waiting, reserve }`), `poolSize`, `defaultConnectionReserve`, `RESERVE_ESCAPE_MS` (deployment.md §4.3a) |
|
||||
| Payload's "forgot password" / "verify your e-mail" through `mailAdapter()` go out right after their transaction commits (same request); a rolled-back operation sends nothing | `mail: { accountMailAfterCommit: false }` | your own adapter: `sendAccountMailAfterCommit(message, send)`; `withAccountMailAfterCommit(collection)`, `holdAccountMail`, `releaseAccountMail` (email.md "Payload system mail") |
|
||||
| Form e-mails go out right after the submission's transaction commits (same request, same answer); a rolled-back submission sends nothing; a send that fails after the commit leaves the submission stored. No transactions (MongoDB without a replica set, SQLite): at once, as before | `forms: { emailsInTransaction: true }` | `sendAfterCommit(prepare, deliver)`, `sendFormEmails(req, emails)`, `afterCommit(req, fn)` (forms.md "When e-mails go out") |
|
||||
| SMTP time-outs: 10 s to connect, 30 s greeting, 60 s silence | — | `mailAdapter({ smtp: { timeouts: { connectionMs, greetingMs, socketMs } } })`, `panelSmtpAdapter({ timeouts })`; `SMTP_TIMEOUT_DEFAULTS`, type `SmtpTimeouts` (email.md "SMTP") |
|
||||
|
||||
### 7.2 E-mail — the mail service (default), SMTP (on request), Graph (deprecated)
|
||||
|
||||
|
||||
@@ -121,6 +121,10 @@ through this procedure. Ask only when you are missing something you cannot get y
|
||||
| replies to the site's mail are lost | "Sender address" is empty: the service's own address has no mailbox | fill it in (doctor: `mail-reply-address`) |
|
||||
| the site enrols again and again (`reverify` in the log) | requests leave from many changing addresses (serverless, a pool of egress addresses) | Intecion raises the site's limit of server addresses, or SMTP |
|
||||
| start log: "Microsoft Graph as the e-mail transport is deprecated" | `GRAPH_*` is set | email.md "Moving off Microsoft Graph"; silence only: `mail: { graphDeprecationWarning: false }` |
|
||||
| Postgres: under load (many form submissions or "forgot password" requests at once) the whole site stops answering, also pages that only read; `pg_stat_activity` shows the pool's connections "idle in transaction" | each transaction holds a connection and waits for a second one (code inside it without `req`); before 1.17.0, or with `connectionReserve: false` | upgrade / remove `connectionReserve: false`; without `iapl()` call `reserveConnections(payload)` in `onInit`; your own hooks: pass `req` to every Local API call; `transactionWatchState(payload)` shows `{ active, waiting, reserve }` (deployment.md §4.3a) |
|
||||
| Postgres: requests are slow while a mail server hangs (logins and saves wait behind "forgot password") | the account mail is sent inside its transaction: `mail: { accountMailAfterCommit: false }`, `forms.emailsInTransaction: true`, or an e-mail adapter of your own that does not call `sendAccountMailAfterCommit` | remove the option / call it in your adapter; fix the mail server; shorter `mailAdapter({ smtp: { timeouts } })` |
|
||||
| Postgres: a project hook writes without `req` and the log row stays when its submission is rolled back | a Local API call without `req` is a transaction of its own (it no longer blocks the pool, but it is not rolled back with its caller) | pass `req` to every Local API call in a hook |
|
||||
| a submission is stored but its e-mail never arrived, nothing in the panel status | the transaction was rolled back after the e-mail was composed (then nothing is stored either), or the process ended right after the commit | server log `[iapl] A step that runs after a transaction commits failed` / form-builder's "Error while sending email"; forms.md "When e-mails go out" |
|
||||
| old email sender | mail client cache | check the raw headers |
|
||||
| form: `unknown_fields` | field outside the definition (honeypot not removed) | `iapl-form` → actions.ts |
|
||||
| an account logs in to `/admin` and sees "Unauthorized" (its API calls still work) | `accounts.panelRole`: the panel opens for `editor` and above; the account has only `user`, or no role | give it `editor` (an admin edits the account), or `accounts: { panelRole: 'user' }`; nobody can get in: a script with the Local API sets `roles: ['admin']`, or `accounts: { panelRole: false }` + redeploy |
|
||||
|
||||
@@ -120,6 +120,12 @@ Tell the client plainly: **there is no antivirus scan** (the e-mail says so), th
|
||||
files is best-effort, and when the e-mail cannot be sent the file is gone — the visitor sees "We could not send the
|
||||
file …" at the File field, staff get a notice without the file, and the submission shows **File delivery: Not sent**.
|
||||
|
||||
### E-mails go out after the save (1.17.0)
|
||||
A form's e-mails are composed inside the submission's transaction and sent right after it commits, in the same
|
||||
request (`submitForm` answers as before). A submission rolled back by a hook of yours sends nothing. Keep the old way
|
||||
only on the owner's word: `forms: { emailsInTransaction: true }` (forms.md "When e-mails go out"). Check on Postgres:
|
||||
a submission arrives; your own `afterChange` hooks on form-submissions pass `req` to every Local API call.
|
||||
|
||||
## 4. Page — block data once (blocks do not import `lib/*`)
|
||||
From `createPageRoute` (PROGRAMISTA §2.8):
|
||||
```tsx
|
||||
|
||||
@@ -584,6 +584,12 @@ PROGRAMISTA §6, item 73; email.md; AGENT.md §7.2) — nothing to run; read whi
|
||||
service returns `{ sent, transport: 'relay', … }`; `sent: false` with `confirmed: false` means "may have been sent".
|
||||
5. Your own account mail (invitations): mark it — `withMailKind(message, 'account')`. Form mail and Payload's
|
||||
"forgot password" are marked by the plugin.
|
||||
6. **Postgres sites** (nothing to run): at most `pool size − reserve` transactions are open at once (default reserve 2 of
|
||||
10; `connectionReserve`; a transaction begun inside another one takes no place), form e-mails and Payload's
|
||||
"forgot password" / "verify your e-mail" go out right after their transaction commits (`forms.emailsInTransaction`,
|
||||
`mail.accountMailAfterCommit`),
|
||||
SMTP gives up sooner (10 s to connect, 60 s of silence; `smtp.timeouts`). A site that set its own `pool.max`: the
|
||||
reserve follows it. MongoDB and SQLite sites: no change. deployment.md §4.3a, forms.md "When e-mails go out".
|
||||
**Check:** `pnpm exec iapl-doctor --deep --url <site>` → no `mail-transport` / `mail-relay-state` / `mail-reply-address` /
|
||||
`mail-relay-route` finding (or only `mail-graph-deprecated` on a Graph site); Site integrations → E-mail sending →
|
||||
**Send test e-mail** names the transport you expect; a form submission arrives. **The service has to be live for a site
|
||||
|
||||
Reference in New Issue
Block a user