一键导入
connection-pool-tuning
Tune sqlx PgPool size, idle_timeout, max_lifetime, acquire_timeout. Diagnose pool exhaustion and 'pool timed out' errors.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Tune sqlx PgPool size, idle_timeout, max_lifetime, acquire_timeout. Diagnose pool exhaustion and 'pool timed out' errors.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Bump the patch version in server/Cargo.toml or website/package.json after completing a major change. Use when the user asks to bump/release a version, or when CLAUDE.md's rule about version bumps after major changes applies.
Before a non-trivial change, list affected systems — DB schema, API contract, Telegram handlers, jobs, TS types, docs. Catch ripple effects upfront, not after CI fails. Use when planning a feature, migration, refactor, or any cross-module touch.
Self-review before push — read the diff as a reader, scan for vixen footguns (token leaks, PII, idempotency, captcha asset overwrites), run validation pipeline, no surprise files. Use before "git push", before opening a PR, or when the user says "ready to commit".
Write a git commit message for vixen-rs following the project's Conventional Commits convention. Use when the user asks to commit, create a commit, or write a commit message.
Reproduce → bisect → root cause → fix → verify. Don't speculate, don't "add more error handling" as a guess. Use when something is broken, when a test fails intermittently, when the user says "this isn't working" or "investigate why".
Write small, fast, reproducible Dockerfiles for the vixen-rs server (Rust) and website (bun) using multi-stage builds, cache mounts, distroless/alpine runtime images, and non-root users. Use when editing server/Dockerfile, website/Dockerfile, docker-compose.yml, or when the user asks to shrink an image or speed up a Docker build.
| name | connection-pool-tuning |
| description | Tune sqlx PgPool size, idle_timeout, max_lifetime, acquire_timeout. Diagnose pool exhaustion and 'pool timed out' errors. |
Source: SQLx PoolOptions docs.
Read first:
min_connections = 2 — pre-warm; cuts first-request latency.max_connections = 10 — single-tenant doesn't need more; Postgres max_connections (default 100) is comfortably above.idle_timeout = 600s — close idle conns after 10 min (cost saver on managed DB).max_lifetime = 30 min — retire conns periodically; prevents long-lived bugs (TCP wedge, server upgrade).acquire_timeout = 5s — bound wait time so pool exhaustion fails fast instead of cascading.test_before_acquire = true — ping before returning; catches stale conns after network blips.let pool = sqlx::postgres::PgPoolOptions::new()
.min_connections(2)
.max_connections(10)
.idle_timeout(Duration::from_secs(600))
.max_lifetime(Duration::from_secs(1800))
.acquire_timeout(Duration::from_secs(5))
.test_before_acquire(true)
.connect(&database_url).await?;
error: pool timed out while waiting for an open connection.SELECT * FROM pg_stat_activity WHERE application_name LIKE 'vixen%'; — see what each conn is doing.pool.size() (total open) and pool.num_idle() (free)./health/pool endpoint that exposes both for ops.let _conn = pool.acquire().await? — unused holding; drop explicitly or scope-bound..fetch_all() returning 100k rows — fix with keyset pagination, not a bigger pool.bot.send_*().await inside, you've held it 30s+.pool.begin() ... tx.commit().transaction-discipline skill.idle_timeout lower than their pause threshold to avoid cold-start latency on next use.LISTEN/NOTIFY and prepared statements; use session mode or skip the pooler. SQLx prepared-statement cache assumes session-pinning.cargo test --lib pool (sanity)./health 50 concurrent for 60s; pool size should stay ≤ max, idle should recover.pg_stat_activity.state_change to confirm conns return to idle, not stuck idle in transaction.transaction-discipline, postgres-optimization, tracing-spans.