Postgres: many requests at once no longer stop the site
Each Payload transaction holds a pool connection; code inside it that runs without its req needs a second one (Payload's own forgotPassword, the mail adapter's settings read and status write, payload.kv). With the default pool of 10, ten form submissions or ten "forgot password" requests at once held every connection and waited for good. - connectionReserve (default on): at most pool size − reserve transactions open at once; a waiter older than a second may use all but the last connection. Building blocks in modules/database/transactions.ts. - Form e-mails go out right after the submission's transaction commits, in the same request (forms.emailsInTransaction: true = the old way). - recordIntegrationStatus merges identical writes and does not hold its caller while the pool is busy. - SMTP time-outs: 10 s connect, 30 s greeting, 60 s silence (smtp.timeouts). Tests on Postgres 17: 30 submissions, 30 forgot-password, and both against an SMTP server that never answers, finish while a page answers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
acfcf72c03
commit
32bb542e8e
@@ -30,6 +30,7 @@ import { buildCookieScanEndpoints } from './modules/consent/scanner/endpoint.js'
|
||||
import { mergeCookieScanLabels } from './modules/consent/scanner/labels.js'
|
||||
import { buildConstructionFields } from './modules/construction/fields.js'
|
||||
import { buildArchiveFields } from './modules/content/index.js'
|
||||
import { defaultConnectionReserve, poolSize, watchTransactions } from './modules/database/transactions.js'
|
||||
import { buildDoctorEndpoint } from './modules/doctor/status.js'
|
||||
import { GRAPH_DEPRECATION_NOTICE, graphAvailable } from './modules/email/mailAdapter.js'
|
||||
import { withAccountMailMark } from './modules/email/relay/accountMail.js'
|
||||
@@ -939,6 +940,9 @@ export const iapl = (options: IaplOptions): Plugin => {
|
||||
)
|
||||
}
|
||||
adoptConfig(payload)
|
||||
// Postgres: keep a few pool connections free of transactions (connectionReserve), and watch commits so
|
||||
// that form e-mails go out after the submission's transaction (forms.emailsInTransaction).
|
||||
watchTransactions(payload, options.connectionReserve === false ? false : (options.connectionReserve ?? defaultConnectionReserve(poolSize(payload) ?? 10)))
|
||||
// Microsoft Graph is deprecated (removed in 2.0): one warning per start while its variables are set.
|
||||
if (graphAvailable() && options.mail?.graphDeprecationWarning !== false) {payload.logger.warn(GRAPH_DEPRECATION_NOTICE)}
|
||||
// Payload's dev reload swaps `payload.config` and runs no onInit: adopt the new config at once.
|
||||
|
||||
Reference in New Issue
Block a user