Stop the health-check error loop on Postgres connection exhaustion (BIT-33548) #321
Closed
jos-alves
wants to merge 1 commits from
task/BIT-33548-health-connection-exhaustion into main
pull from: task/BIT-33548-health-connection-exhaustion
merge into: BitReport.pt:main
BitReport.pt:main
BitReport.pt:fix/BIT-34038-deploy-anti-downgrade
BitReport.pt:fix/BIT-33558-cloud-target-p2037-transient
BitReport.pt:fix/BIT-33539-archive-rebuild-directory-pk-race
BitReport.pt:fix/BIT-33549-develop-poll-pool-exhaustion-transient
BitReport.pt:fix/BIT-33550-archive-p2037-transient
BitReport.pt:fix/BIT-33527-pg-client-not-queryable-transient
BitReport.pt:fix/BIT-33540-arquivo-500-graceful-degradation
BitReport.pt:fix/BIT-33537-p2037-connection-exhaustion-filter
BitReport.pt:fix/BIT-33535-galleries-500-graceful-degradation
BitReport.pt:fix/BIT-33532-cloudfile-p2002-race
BitReport.pt:fix/BIT-33530-worker-deploy-connection-overlap
BitReport.pt:task/gitea-319-leiria-unsure-picks
BitReport.pt:task/gitea-317-ud-leiria-rest
BitReport.pt:task/autopilot-fair-split
BitReport.pt:task/cloud-w17
BitReport.pt:task/w17-fold-friendly
BitReport.pt:task/ehf-checklist-update-hint
BitReport.pt:task/w17-ehf-euro
BitReport.pt:task/zerozero-publish-403
BitReport.pt:task/BIT-33418-retry-race-condition
BitReport.pt:task/zerozero-publish-game
BitReport.pt:task/BIT-33402-desktop-self-update
BitReport.pt:task/BIT-33405-context-menu-date-flake
BitReport.pt:task/BIT-30361-manual-payment
BitReport.pt:task/BIT-33293-autopilot-ci
BitReport.pt:task/BIT-33293-autopilot-tests
BitReport.pt:task/lightroom-roundtrip
BitReport.pt:task/lightroom-file-metadata
BitReport.pt:task/lightroom-metadata-on-file
BitReport.pt:task/reportage-clear-subject
BitReport.pt:task/BIT-33124-disk-marks-reliable
BitReport.pt:task/BIT-33124-read-disk-marks
BitReport.pt:task/BIT-32879-crop-clean-framing
BitReport.pt:fix/BIT-32855-bound-boot-health-wait
BitReport.pt:task/gitea-294-trust-the-frame
BitReport.pt:task/BIT-32810-transaction-closed-transient
BitReport.pt:fix/BIT-32083-transaction-timeout-guard
BitReport.pt:task/gitea-287-joga-tls
BitReport.pt:task/autopilot-original-aspect
BitReport.pt:task/gitea-287-joga-client
BitReport.pt:task/gitea-287-fpf-squad-season
BitReport.pt:task/gitea-285-taca-portugal-fpf
BitReport.pt:task/BIT-32490-reporter-transient-db-filter
BitReport.pt:fix/BIT-31961-sports-headshot-fetch-failed
BitReport.pt:task/BIT-32481-p1017-linkSquadPerson-test
BitReport.pt:task/BIT-32491-boot-pm2-timeout
BitReport.pt:fix/BIT-32475-sports-p1017-connection-closed-retry-exhausted
BitReport.pt:fix/BIT-32474-sports-57p03-personforidentity
BitReport.pt:fix/BIT-32473-archive-57p01-admin-shutdown
BitReport.pt:fix/BIT-32469-archive-p2010-unreachable
BitReport.pt:fix/BIT-32471-sports-57p01-admin-shutdown
BitReport.pt:fix/BIT-32470-sports-57p03-shutdown
BitReport.pt:fix/BIT-32463-sports-p1001-unreachable
BitReport.pt:fix/BIT-32462-archive-pg-unreachable
BitReport.pt:fix/BIT-32460-sports-p1017-connection-closed
BitReport.pt:fix/BIT-32449-develop-pg-admin-shutdown
BitReport.pt:fix/BIT-32450-faces-pg-admin-shutdown
BitReport.pt:fix/BIT-32447-pg-pool-error-handler
BitReport.pt:task/BIT-265-autopilot-rest-warmup-picks
BitReport.pt:task/BIT-262-flush-work-folder-xmp
BitReport.pt:task/BIT-262-work-folder-xmp
BitReport.pt:task/client-galleries
BitReport.pt:task/BIT-257-keep-football
BitReport.pt:task/BIT-257-archived-pin
BitReport.pt:fix/BIT-31961-stripe-invoicexpress-fetch-failed
BitReport.pt:task/BIT-251-catch-up
BitReport.pt:task/BIT-251-preview-clock
BitReport.pt:task/BIT-251-winter-clock
BitReport.pt:task/BIT-249-frame-intent
BitReport.pt:task/BIT-247-desktop-update
BitReport.pt:task/BIT-245-gallery-ceiling
BitReport.pt:task/BIT-243-galleries
BitReport.pt:task/BIT-241-zerozero-credit
BitReport.pt:task/BIT-239-loupe
BitReport.pt:task/BIT-237-desk
BitReport.pt:task/BIT-235-mcp-assistant
BitReport.pt:task/BIT-233-quiet-chrome
BitReport.pt:fix/BIT-32083-upsert-maxwait
BitReport.pt:fix/BIT-32086-liga-squad-reread-400
BitReport.pt:fix/BIT-32085-sports-youth-m19-regression
BitReport.pt:fix/BIT-32084-ci-regression-tests
BitReport.pt:task/BIT-228-library-bar
BitReport.pt:task/BIT-226-clean-panels
BitReport.pt:task/BIT-224-desktop-031
BitReport.pt:task/BIT-222-squad-faces
BitReport.pt:task/BIT-220-cull-bar
BitReport.pt:task/BIT-218-uncolored-menus
BitReport.pt:task/BIT-216-republish-app
BitReport.pt:task/BIT-214-drag-select
BitReport.pt:task/BIT-212-color-without
BitReport.pt:task/BIT-210-stale-event-drop
BitReport.pt:task/BIT-208-pm-color
BitReport.pt:task/BIT-205-fpa-club-town
BitReport.pt:task/BIT-203-stadium-city
BitReport.pt:task/BIT-201-kit-light
BitReport.pt:task/BIT-199-keep-sure-face
BitReport.pt:task/BIT-197-faces-rank-kit
BitReport.pt:task/BIT-195-faces-number-and-photo-menu
BitReport.pt:task/BIT-193-iptc-caption-empty-location
BitReport.pt:task/BIT-190-desktop-0.3.29-cropbias
BitReport.pt:task/BIT-190-card-ingest-macos-free-space
BitReport.pt:task/BIT-lr-crop-xmp
BitReport.pt:task/m19-youth-cloud
BitReport.pt:fix/BIT-31903-headshot-unsupported-format
BitReport.pt:task/BIT-185-faces-before-references
BitReport.pt:task/BIT-184-create-event
BitReport.pt:task/BIT-182-picker-people
BitReport.pt:fix/BIT-32057-events-transaction-maxwait
BitReport.pt:task/BIT-180-eurocup-fixtures
BitReport.pt:task/BIT-179-snam-national-faces
BitReport.pt:task/BIT-177-autopilot-delivery-identity
BitReport.pt:task/BIT-174-lr-pick-xmp
BitReport.pt:task/BIT-173-export-pick-xmp
BitReport.pt:fix/BIT-32041-drop-if-empty-deadlock
BitReport.pt:task/BIT-172-best-honour-count
BitReport.pt:task/BIT-171-local-burst-autopilot
BitReport.pt:task/BIT-170-pick-eyes-level-edit
BitReport.pt:task/BIT-169-crop-face-focus
BitReport.pt:task/BIT-168-usb-no-dup-copies
BitReport.pt:task/BIT-167-upload-queue-unstick
BitReport.pt:task/BIT-166-usb-pin-no-exif
BitReport.pt:task/BIT-165-event-routing
BitReport.pt:task/BIT-163-originals-transfer-bar
BitReport.pt:task/BIT-161-local-first-remove
BitReport.pt:task/BIT-159-usb-shootable-tether
BitReport.pt:task/BIT-157-desktop-auto-ui-reload
BitReport.pt:task/BIT-155-send-originals-visible
BitReport.pt:task/BIT-153-send-originals-face-resend
BitReport.pt:task/BIT-151-delivery-no-face-wait
BitReport.pt:task/BIT-149-ingest-hour-gap
BitReport.pt:task/BIT-144-usb-catalog-perf
BitReport.pt:task/BIT-146-camera-rating-ingest
BitReport.pt:fix/BIT-32038-usb-status-files-undefined
BitReport.pt:task/BIT-usb-event-window
BitReport.pt:task/BIT-usb-card-import
BitReport.pt:task/BIT-retract-orphan-reconcile
BitReport.pt:task/BIT-desktop-update-sig-guard
BitReport.pt:task/BIT-134-usb-tether
BitReport.pt:fix/BIT-31961-desktop-download-fetch-failed
BitReport.pt:task/BIT-31700-vips-sos-corrupt-source
BitReport.pt:fix/BIT-31898-fpa-associate-name-collision
BitReport.pt:task/126-selfie-camera
BitReport.pt:task/126-find-registry-first
BitReport.pt:task/126-archive-find-speed
BitReport.pt:task/126-archive-find-by-photo
BitReport.pt:task/archive-licence
BitReport.pt:task/folder-develop-upload
BitReport.pt:task/folder-merge-dng
BitReport.pt:task/BIT-31725-node24-upgrade
BitReport.pt:task/folder-drop-window
BitReport.pt:task/contact-sheet-remove
BitReport.pt:backup/stash-20261025-photoreport-0
BitReport.pt:fix/BIT-31658-ffmpeg-map-corrupt-source
BitReport.pt:task/index-added-photos
BitReport.pt:task/BIT-31658-archive-hub-noise
BitReport.pt:fix/BIT-31621-moov-corrupt-source
BitReport.pt:fix/BIT-31229-unsupported-image-format
BitReport.pt:fix/BIT-31203-event-vanished-race
BitReport.pt:task/club-siglas
BitReport.pt:task/BIT-31680-dropifempty-deadlock-retry
BitReport.pt:fix/BIT-31622-no-video-stream-skip
BitReport.pt:task/main-red-app-tests
BitReport.pt:task/ehf-fixtures
BitReport.pt:task/squad-reindex
BitReport.pt:task/people-season
BitReport.pt:task/lineup-photo
BitReport.pt:task/selection-rules
BitReport.pt:task/season-squads
BitReport.pt:task/faces-roster
BitReport.pt:task/merge-collection
BitReport.pt:task/86-confirm-fuse
BitReport.pt:task/84-progress-export
BitReport.pt:task/faces-confirm
BitReport.pt:task/80-camera-clock
BitReport.pt:task/78-card-offload
BitReport.pt:task/capture-meta
BitReport.pt:task/archive-video-faces-queue
BitReport.pt:task/archive-video-faces
BitReport.pt:task/archive-video
BitReport.pt:task/archive-directory-stored
BitReport.pt:task/crop-sport-ball
BitReport.pt:task/crop-clean-edge
BitReport.pt:task/help-faq
BitReport.pt:task/filmstrip-filter
BitReport.pt:task/softer-highlights
BitReport.pt:task/library-sync
BitReport.pt:task/archive-not-live
BitReport.pt:task/sequence-crop
BitReport.pt:task/offline-preview
BitReport.pt:task/upload-expired-token
BitReport.pt:task/whole-figure
BitReport.pt:task/detail-and-speed
BitReport.pt:task/export-lift
BitReport.pt:task/reportage-heads
BitReport.pt:task/keep-foot-at-the-edge
BitReport.pt:task/reportage-crop
BitReport.pt:task/keep-whole-feet
BitReport.pt:task/stale-ftp-pin
BitReport.pt:task/archive-design-phase2
BitReport.pt:task/archive-design-phase1
BitReport.pt:task/archive-one-gallery
BitReport.pt:task/archive-slash-sponsor
BitReport.pt:task/archive-teams-fast
BitReport.pt:task/autopilot-agency-style
BitReport.pt:task/liga-sheet-faces
BitReport.pt:task/faces-recent-month
BitReport.pt:task/ci-green
BitReport.pt:task/desktop-folder-permissions
BitReport.pt:task/archive-templates
BitReport.pt:task/archive-teams-and-search
BitReport.pt:task/archive-game-local-copy
BitReport.pt:task/squad-player-filter
BitReport.pt:task/jpeg-complete
BitReport.pt:task/send-by-output
BitReport.pt:task/pm-info-review
BitReport.pt:task/delivery-names-local-copy
BitReport.pt:task/desktop-bundle-script
BitReport.pt:task/develop-crop-lightroom
BitReport.pt:task/folder-scan-progress
BitReport.pt:task/folder-scan-background
BitReport.pt:task/gpu-and-cpu-faces
BitReport.pt:fix/BIT-31393-face-worker-exit
BitReport.pt:task/local-folder-faces
BitReport.pt:task/scan-game-then-rest
BitReport.pt:task/scan-one-game
BitReport.pt:task/ship-folder-search
BitReport.pt:task/archive-viewer-pages
BitReport.pt:task/delivery-retracted-label
BitReport.pt:task/autopilot-hand-uploads
BitReport.pt:task/delivery-retract-unwanted
BitReport.pt:task/ship-pending
BitReport.pt:task/face-queue-boost
BitReport.pt:task/BIT-31305-undici-socket-end-assertion-guard
BitReport.pt:task/library-remember-target
BitReport.pt:task/ingest-original-responder-serial
BitReport.pt:task/ingest-truncated-jpeg
BitReport.pt:fix/BIT-31189-prisma-pool-after-end
BitReport.pt:fix/BIT-31177-pg-pool-after-end
No Reviewers
Labels
No items
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Assignees
artur (Artur Moreira)
artur-moreira (Artur Moreira)
automation-engineer (José Alves)
bug-squasher (Bug Squasher)
coo (Rosa Neves)
cto (Peter Spark)
database-engineer (Diana Neves)
david-santos (David Santos)
devops-engineer (Tiago Neves)
eduardo (Eduardo Henriques)
eduardo-henriques (Eduardo Henriques)
founding-engineer (David Santos)
jos-alves (José Alves)
maria (Maria Papoila)
maria-papoila (Maria Papoila)
miguel-teixeira (Miguel Teixeira)
nelson-alves (Nelson Alves)
nelson-baptista (Nelson Baptista)
netsec-engineer (Nuno Santos)
paperclip-merge-bot
paperclip-review-bot
patr-cia-santos (Patrícia Santos)
paula-alves (Paula Alves)
peter-spark (Peter Spark)
php-re-specialist (Pedro Alves)
planner (Patrícia Santos)
qa-engineer (Paula Alves)
rosa-neves (Rosa Neves)
security (Sérgio Rodrigues)
spark
tiago-neves (Tiago Neves)
xika (Xika)
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: BitReport.pt/photoreport#321
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
The
/healthendpoint randb.$queryRaw\SELECT 1`with no error handling. When PostgreSQL hitsmax_connections(error 53300 — "remaining connection slots are reserved for roles with the SUPERUSER attribute"), the query threwPrismaClientKnownRequestError`, the error handler logged it as "unhandled error", and the reporter sent it to errors.bitreport.pt — creating an error loop of one-off incidents from every health check.Fix
Two changes:
app.ts— health check degrades gracefully. The/healthendpoint now catches DB failures and returns503 { status: "degraded" }instead of throwing. A connection-starved health check reports degraded health rather than generating an error report.reporter.ts— 53300 added to transient filter.isTransientDatabaseErrornow filters 53300 (pool exhaustion) alongside the existing 57P01/57P03/P1001/P1017 filters, so even if a 53300 surfaces through another code path it does not trip the error loop.Tests
reporter.test.ts: added 53300 to the existing transient DB error suppression test.auth.test.ts: added a test that verifies/healthreturns 503{ status: "degraded" }when the database is unreachable.Build and typecheck pass. The reporter filter and health-check degradation were both verified against the compiled output.
Paperclip-Issue: BIT-33548
The /health endpoint ran db.$queryRaw`SELECT 1` with no error handling. When PostgreSQL hits max_connections (error 53300), the query threw PrismaClientKnownRequestError, the error handler logged it as 'unhandled error', and the reporter sent it to errors.bitreport.pt — creating an error loop of one-off incidents from every health check. Two fixes: - /health now catches DB failures and returns 503 { status: 'degraded' } instead of throwing, so a connection-starved health check degrades gracefully rather than generating an error report. - isTransientDatabaseError now filters 53300 (pool exhaustion) alongside the existing 57P01/57P03/P1001/P1017 filters, so even if a 53300 surfaces through another code path it does not trip the error loop. Paperclip-Issue: BIT-33548Pull request closed