{"record":{"id":"c8fe0b75d7cdc8f9","repo":"bytedance/deer-flow","slug":"gateway-workers-workers-requires-database-backen","errorCode":null,"errorMessage":"GATEWAY_WORKERS={workers} requires database.backend='postgres', but database.backend is '{backend}'. SQLite cannot support concurrent multi-process access. Set GATEWAY_WORKERS=1 or switch to Postgres.","messagePattern":"GATEWAY_WORKERS=(.+?) requires database\\.backend='postgres', but database\\.backend is '(.+?)'\\. SQLite cannot support concurrent multi-process access\\. Set GATEWAY_WORKERS=1 or switch to Postgres\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"critical","filePath":"backend/app/gateway/deps.py","lineNumber":112,"sourceCode":"\n    if multi_instance_requested and backend != \"postgres\":\n        raise SystemExit(f\"scheduler.multi_instance=true requires database.backend='postgres'. database.backend is '{backend}'. Set scheduler.multi_instance=false or configure Postgres.\")\n    if multi_instance_requested and run_events_backend != \"db\":\n        raise SystemExit(f\"scheduler.multi_instance=true requires run_events.backend='db'. run_events.backend is '{run_events_backend}'. Set scheduler.multi_instance=false or configure run_events.backend: db.\")\n    if multi_instance_requested and (run_ownership is None or not run_ownership.heartbeat_enabled):\n        raise SystemExit(\"scheduler.multi_instance=true requires run_ownership.heartbeat_enabled=true so peer runs retain a valid lease. Set scheduler.multi_instance=false or enable run ownership heartbeats.\")\n\n    if workers <= 1:\n        return\n\n    if config.scheduler.enabled and not multi_instance_scheduler:\n        raise SystemExit(f\"GATEWAY_WORKERS={workers} cannot run with scheduler.enabled=true because each worker starts its own scheduler. Set GATEWAY_WORKERS=1, scheduler.multi_instance=true, or scheduler.enabled=false.\")\n\n    if _browser_tools_enabled_in_config(config):\n        raise SystemExit(browser_multi_worker_error(workers))\n\n    if backend != \"postgres\":\n        raise SystemExit(f\"GATEWAY_WORKERS={workers} requires database.backend='postgres', but database.backend is '{backend}'. SQLite cannot support concurrent multi-process access. Set GATEWAY_WORKERS=1 or switch to Postgres.\")\n\n    if run_events_backend != \"db\":\n        raise SystemExit(\n            f\"GATEWAY_WORKERS={workers} requires run_events.backend='db', but run_events.backend is '{run_events_backend}'. \"\n            \"Memory and JSONL event stores are process-local, so delivery receipt singleton guarantees cannot hold across workers. \"\n            \"Set GATEWAY_WORKERS=1 or configure run_events.backend: db.\"\n        )\n\n    if run_ownership is None or not run_ownership.heartbeat_enabled:\n        raise SystemExit(\n            f\"GATEWAY_WORKERS={workers} requires run_ownership.heartbeat_enabled=true. \"\n            \"Without heartbeat, every run has a NULL lease, so reconciliation \"\n            \"treats all inflight runs as orphans — Worker B would kill Worker A's \"\n            \"live runs on every rolling update or scale-up. \"\n            \"Set run_ownership.heartbeat_enabled=true in config.yaml.\"\n        )\n\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/deps.py#L94-L130","documentation":"SystemExit raised at startup when GATEWAY_WORKERS>1 but database.backend is not 'postgres'. SQLite cannot support concurrent multi-process access (single-writer, file-lock semantics), so N worker processes against one sqlite file would corrupt or serialize; the gate restricts multi-worker mode to Postgres.","triggerScenarios":"GATEWAY_WORKERS>1 with database.backend: sqlite (or memory) in config.yaml; reached after the scheduler and browser-tool checks pass.","commonSituations":"Bumping GATEWAY_WORKERS on a dev-default sqlite config for a load test; moving a compose file to replicas without migrating the database; mis-set DATABASE_URL leaving backend resolution at sqlite.","solutions":["Set GATEWAY_WORKERS=1","Or migrate to database.backend: postgres with a valid shared Postgres URL","Restart the Gateway"],"exampleFix":"# config.yaml\n# before\ndatabase:\n  backend: sqlite\n# after\ndatabase:\n  backend: postgres\n  url: postgresql+asyncpg://user:pass@host/deerflow","handlingStrategy":"validation","validationCode":"workers = int(os.environ.get(\"GATEWAY_WORKERS\", \"1\"))\ncfg = load_config()\nassert not (workers > 1 and cfg.database.backend != \"postgres\"), \"multi-worker needs postgres\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision Postgres before raising GATEWAY_WORKERS above 1","Never point N workers at one sqlite file — the gate exists because sqlite is single-writer","Smoke-test config in a staging container with the production env vars before deploy"],"tags":["config","startup","postgres","sqlite","workers","system-exit","gateway"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}