Skip to content

[bug] Three startup tasks stall the server at database.max_connections=1 #5247

Backlog

Description

@Quick104

What happened

With database.max_connections set to 1, a server stops answering database requests shortly after it starts. /api/v1/ready reports postgres: false and authenticated API calls time out. It stayed that way for the several minutes I watched, and a restart stalls it again.

Three tasks that run at startup take their advisory lock with pglock.TryAcquire, which keeps one of the pool's connections until the task ends, and then query through the same pool. With a pool of one connection, the task's first query waits on the connection its own lock holds, and so does every other query on the server:

  • generate_extra_stills: Generator.Generate in internal/extrastills/generator.go takes lockKey (SILOEXT) and then queries through g.pool.
  • release_stored_artwork: NewStoredArtworkReleaser in internal/metadata/artwork_release.go takes storedArtworkReleaseAdvisoryLock (SILORELS) and Run then queries through r.pool.
  • cleanup_chapter_thumbnail_originals: OriginalsCleaner.Exclusive in internal/chapterthumbs/originals_cleanup.go takes originalsCleanupAdvisoryLock and runs fn, whose Page queries through c.pool.

This is the same stall #5111 describes for the task history cleanup. #5197 fixes that one by holding the lock on a database session of its own (pglock.TryAcquireSession), and leaves these callers for follow-ups.

Steps to reproduce

Reproduced on a Silo dev deployment built from main at 05b39b6.

  1. Set database.max_connections to 1 and restart.
  2. Within seconds of startup, /api/v1/ready returns 503 with postgres: false.
  3. pg_stat_activity for the Silo database shows the pool's only connection idle with SELECT pg_try_advisory_lock($1) as its last query, holding SILOEXT (extra stills).
  4. Give generate_extra_stills an empty schedule and restart. The server is ready for a few seconds, then stalls the same way with the connection holding SILORELS (stored artwork release).
  5. Give release_stored_artwork and cleanup_chapter_thumbnail_originals empty schedules too and restart. The server stays ready.

The chapter thumbnail cleanup was confirmed from the source only, since the other two took the connection first in this reproduction.

Expected behavior

Each task runs on a one-connection pool. It could hold its lock on a session outside the pool with pglock.TryAcquireSession once #5197 merges, or run its queries on lock.Conn().

Silo version / commit

main at 05b39b6

Deployment

Any deployment with database.max_connections set to 1, with these tasks on their default schedules.

Clients affected

None directly. Server-side stall.

Relevant logs

time=...Z level=WARN msg="node credential reload failed; keeping the credentials already loaded" component=nodepool error="list node credentials: context deadline exceeded"
 pid | state |    idle_for     |                q                |      locks
-----+-------+-----------------+---------------------------------+------------------
 ... | idle  | 00:02:28.554213 | SELECT pg_try_advisory_lock($1) | 53494c4f455854

Technical notes

This issue follows #5197, which adds pglock.TryAcquireSession. Other pglock.TryAcquire callers listed in #5111's technical notes are still unchecked; these three are the ones that stall a server at startup with no admin action.

Defect: silo-server internal/extrastills/generator.go Generator.Generate
Defect: silo-server internal/metadata/artwork_release.go NewStoredArtworkReleaser
Defect: silo-server internal/chapterthumbs/originals_cleanup.go OriginalsCleaner.Exclusive

AI disclosure

  • Harness: Claude Code in T3 Code
  • Tools: Claude Code
  • Model: claude-opus-5-5
  • Involvement: Fully AI-generated
  • Independent review: none

Confirmations

  • I searched existing issues.
  • Reproduced on a real deployment.

Source: found in review of #5197

Activity

  1. added
    bug
    on Nov 24, 2026
  2. added
    impact: usability
    priority: P2
    triaged
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugimpact: usabilitypriority: P2triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions