mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-31 18:42:33 +08:00
`TagHandler._create_tag_instance` created the `Tag` in a *separate* session and committed it, to keep a unique-name `IntegrityError` from aborting the caller's transaction. When this runs inside an open write transaction - e.g. applying a tag to an output during workflow job creation - that second connection's commit deadlocks against the first on SQLite's single-writer lock, surfacing intermittently as "(sqlite3.OperationalError) database is locked" and failing the job (and the workflow invocation). It is timing sensitive, so any small latency in the surrounding code makes it reproducible. Insert the tag on the session's own connection with `INSERT ... ON CONFLICT (name) DO NOTHING` (SQLite and PostgreSQL both support it natively), preserving the duplicate-name isolation without a second connection. Other backends keep the separate-session fallback - the single-writer deadlock is SQLite-specific.