Skip to content

feat(backend): DBOS worker process + enqueue round-trip#4692

Open
marcoacierno wants to merge 3 commits into
mainfrom
setup-dbos
Open

feat(backend): DBOS worker process + enqueue round-trip#4692
marcoacierno wants to merge 3 commits into
mainfrom
setup-dbos

Conversation

@marcoacierno

@marcoacierno marcoacierno commented Jun 22, 2026

Copy link
Copy Markdown
Member

Stack (top to bottom):

marcoacierno and others added 3 commits June 22, 2026 16:19
First step of the DBOS foundation slice (see SPEC.md / tasks/plan.md).
dbos 2.24.0 ships a Python 3.13 wheel; verified import on 3.13.5.
Additive only — Celery/Redis untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Phase A of the DBOS foundation (SPEC.md / tasks/plan.md):
- pycon/dbos_app.py: build_dbos_config() from Django settings + lazy
  get_dbos_client() for the web tier (enqueue-only, never launches DBOS).
- pycon/dbos_workflows.py: minimal healthcheck workflow + step (proof only,
  not wired into any request path).
- settings: DBOS_APP_NAME, DBOS_SYSTEM_DATABASE_URL (postgresql:// scheme),
  DBOS_SYS_DB_POOL_SIZE=5 (low on purpose; shared Postgres).
- tests: in-process exec, idempotency (step runs once under same workflow id),
  and config-build. Run against a dedicated dbos_test Postgres DB.

SQLite is unusable as a DBOS system DB in 2.24.0 (migrations are raw Postgres
DDL), so tests use a real Postgres database. Additive only; Celery untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Phase B of the DBOS foundation (SPEC.md / tasks/plan.md):
- manage.py dbos_worker: launches DBOS, registers the shared queue, blocks,
  and shuts down cleanly on SIGTERM/SIGINT. Mirrors the Celery worker role.
- manage.py dbos_enqueue_healthcheck: enqueues the healthcheck workflow via
  DBOSClient (web-tier pattern) and waits for the result.
- dbos_app.py: DBOS_QUEUE_NAME constant shared by producer and consumer.
- dbos_workflows.py: pin explicit workflow name for the enqueue contract.
- settings: register the `pycon` package as an app so its project-level
  management commands are discoverable (it has no models).
- docker-compose: DBOS_SYSTEM_DATABASE_URL on the shared env + a dbos-worker
  service. DBOS auto-creates the `dbos` database on first launch locally.

Verified end to end: enqueue -> worker executes -> result 'ok'. Additive;
Celery/Redis untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pycon Ready Ready Preview Jun 22, 2026 2:47pm

@claude

claude Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This PR introduces DBOS as a durable workflow engine running alongside Celery, scoped to a proof-of-concept healthcheck round-trip. No existing functionality is changed.

Thread safety bug in get_dbos_client() (dbos_app.py):
The lazy singleton uses a bare if _client is None check without a lock. Under multi-threaded gunicorn workers, two threads can race and create two clients simultaneously. Add a threading.Lock around the initialization block.

handle.get_result() blocks indefinitely (dbos_enqueue_healthcheck.py):
If the dbos_worker is not running, this hangs forever. A timeout should be passed or documented.

sys_db_pool_size not forwarded to web-tier client (dbos_app.py):
build_dbos_config() passes sys_db_pool_size to the worker, but get_dbos_client() uses DBOS's internal default. With multiple web workers this could exhaust the connection budget silently. Either pass the setting or document the omission.

No pytest marker for integration tests (test_dbos.py):
The DBOS tests require a live Postgres instance with superuser access to CREATE DATABASE. Without a marker (e.g., @pytest.mark.integration) there's no way to skip them in environments without Postgres, leading to cryptic failures.

References to missing files:
Several comments reference SPEC.md and tasks/plan.md which don't exist in the repo. Either add them or remove the references.

Minor:

  • "pycon" added to INSTALLED_APPS as a bare string rather than a proper AppConfig subclass — since pycon/__init__.py already imports the Celery app, app initialization ordering is worth verifying.
  • dbos-worker docker-compose service has no healthcheck; if other services ever depend on it they'll have no ready signal.
  • psycopg-binary is now installed alongside psycopg[c] — no runtime conflict but adds binary size and is worth noting.

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.89474% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.01%. Comparing base (d249997) to head (ebd4f4c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4692      +/-   ##
==========================================
- Coverage   92.43%   92.01%   -0.42%     
==========================================
  Files         355      359       +4     
  Lines       10719    10795      +76     
  Branches      818      822       +4     
==========================================
+ Hits         9908     9933      +25     
- Misses        698      749      +51     
  Partials      113      113              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant