Skip to content

Troubleshooting

Dmitri Chudinov edited this page Aug 28, 2026 · 1 revision

Troubleshooting

Symptom first. Every entry here is something that has actually happened, and most of them share a shape: the system kept answering 200 while being wrong, which is why they went unnoticed.


The boards load once and then sit still

Symptom. The console's dashboard, post-production or packing board shows correct data on load and never updates while the farm works. Nothing errors.

Cause. The event relay. The API and the workers are separate containers with an in-process bus each, so every event raised by a sweep rather than by a request is published into the worker process and stops there. The boards refetch on an event and on connect, never on a timer — so in production they load once and go quiet.

Check.

curl -s localhost:8080/api/health/ready | jq .checks.event_relay

Then confirm both containers share PRINTORIAN_REDIS_URL and PRINTORIAN_EVENTS_CHANNEL. backend/tools/relay_probe.py proves the hop in the arrangement that ships.


systemd says the farm is up and no containers are running

Symptom. systemctl is-active printorian.service → active. docker ps → nothing.

Cause. Type=oneshot with RemainAfterExit=yes means "ExecStart returned 0 once", not "the farm is running". This happened on the first farm host within an hour of the unit existing.

Fix. systemctl restart, not start — systemd believes the job is done, so start does nothing. And stop using is-active as a health signal: the honest checks are /health/ready and the running container count. printorian-ensure.timer reconciles every five minutes and logs loudly when it has to act.


The backup exists and is worthless

Three distinct versions of this, all silent.

WAL archiving never worked at all. The archive target is mounted into a container running as uid 70 and the mount is owned by root. Every segment fails; nothing surfaces; pg_wal grows until the data disk fills. The development stack reached 1 385 consecutive failures, zero successes, 23 GB of WAL.

docker exec printorian-postgres psql -U printorian -d printorian -c "select archived_count, failed_count, last_failed_error from pg_stat_archiver;"

A full backup disk wedged archiving permanently. archive_command used to copy to the final name, so a full disk left a 786 KB fragment of a 16 MB segment; the test ! -f guard then saw a file and the && chain never ran again — and freeing the disk did not help. It now writes %f.tmp and renames.

The dump is valid, restorable and empty. A backup script pointed at the wrong database name produces one every night and every other check passes. This is what restore_drill.py asserts against — users, orders and payment_notifications are not empty.

/health/ready now reports wal_archiving: degraded, comparing watermarks rather than failed_count (which never resets and would leave a farm red for ever over one bad night in March). There is still no alerting — somebody has to look.


Point-in-time recovery reported success and lost everything recent

Cause. The WAL archive is gzipped. A restore_command that copies %f finds nothing, and PostgreSQL reports the recovery as complete at the last segment it could read rather than failing.

Fix.

restore_command = 'gunzip -c /backup/wal/%f.gz > %p'

A write says it succeeded and is not in the database

Cause. Database.session() commits after the yield, so return from inside async for session in db.session() leaves the generator suspended and the commit never runs. The interpreter finalizes it with GeneratorExit — a BaseException, which slips past the except Exception that would at least have rolled back loudly.

This created the farm's first owner, discarded the insert, printed "Created owner" and exited 0.

Guard. tests/unit/test_session_lifecycle.py walks the AST and fails on the pattern anywhere. If you are writing a new session consumer, do not return from inside that loop.


The console renders in the wrong fonts

Cause. Caddy's CSP said font-src 'self' while Vite inlines the interface font as a data: URI, so every face was blocked and the console fell back.

Note the shape: invisible in development, where the dev server sends no CSP at all.


A worker container is "running" but nothing is happening

Check.

docker compose -f deploy/compose.prod.yml exec workers python -m printorian.workers --check

It reads the beat each loop records at the end of a pass, so it fails for a wedged loop — which a process check cannot see. GET /health/workers reports the same thing by name.

A loop is stale after worker_stale_intervals (default 4) times its own interval.


Two CI runs disagree about the same two rows

Cause. A sort on a timestamp alone. Entity.created_at is a server_default of now(), and PostgreSQL's now() is the transaction's start — so every row one pass writes carries the same timestamp, in production as well as in tests.

Fix. Add id as a second term where the sort is under a LIMIT; a sort that returns a whole set for a screen to render does not need one. Use sequence, not id, for JobEvent and OrderEvent. The idiom is in core/pagination.py.


A new enum value is refused by the database

Cause. Enum columns are VARCHAR with a CHECK. Adding a member in Python is not enough, and alembic check will not catch it — it matches CHECK constraints by name only.

Fix. Write the migration that drops the old constraint and creates the new one. test_every_enum_column_is_checked_in_the_database is what catches the omission.


The API refuses to start in production

Likely cause. An account sits in a domain reserved for documentation. This is deliberate: restoring a developer dump into a real farm is a container that will not come up, rather than a published owner password serving a live farm.

Also check PRINTORIAN_SECRET_KEY — the default is dev-only-not-a-real-secret — and that PAYMENT_PROVIDER is not mock, which refuses to load in production, as does the mock driver.


A printer will not connect

Work the runbook's order — it separates causes that are indistinguishable from a distance and have completely different fixes.

Step 1 — is the machine reachable at all?

cd backend && ./.venv/Scripts/python.exe tools/bambu_spike.py --printer p1s-01

Standalone code importing nothing from Printorian, so a failure here is a network or credentials problem and not a code one. Three failures look similar and are not:

Symptom Means
TLS handshake refused Certificate or port
MQTT CONNACK rejected Access code
No route to host Network, or LAN mode is off on the machine

Step 2 — does the product's driver connect?

cd backend && PRINTORIAN_HARDWARE=p1s-01 ./.venv/Scripts/python.exe -m pytest tests/contract/ -m hardware -v

If step 1 passed and step 2 fails, that is the finding — the protocol works and the driver does not, and the gap is a bug in code you own rather than a fact about the hardware.

Step 3 — does the farm see it? Register it in the console and watch the fleet board. The poller runs every five seconds; the state should leave offline within one sweep.

Uploads fail or listings come back empty. vsftpd defaults to require_ssl_reuse=YES — the data connection must resume the control connection's TLS session, and Python's ftplib negotiates a fresh one.

Full procedure: docs/RUNBOOK-FIRST-PRINT.md.


A job sits on the wait list with no start time

This is correct behaviour, not a bug — if the reason is material_not_loaded or no_capable_printer. Nothing in the system knows when a person will walk over with a spool, and waiting will never help a job no machine can print. Naming a start time would be the queue's version of a driver inventing telemetry.

GET /jobs/wait-list gives the reason; GET /jobs/{id}/decisions gives every candidate machine and why each was refused.


An order is stuck in price_review

Working as designed: the sliced truth exceeded the quote by more than the tolerance (default 15 %), so it is held for a decision rather than silently costing the farm money or silently overcharging the customer.

POST /jobs/{id}/release (needs manage_order), or refund.


Four traps that cost an afternoon each

Piping hides failure. cmd | tail returns tail's exit code. npm ci | tail once reported success while the install had failed, and every check after it ran against a stale node_modules. Use cmd > /tmp/out.log 2>&1; echo "exit=$?".

Documents go stale. Verify a status against the code before repeating it from any document — including this wiki.

An agent's report of its own success is not evidence. Two separate reports of "all gates green" here were produced by runs where the gate had not been executed at all.

Check git status first when picking up interrupted work. A tree that compiles and passes lint can still have no test for the part that matters.

Related

Clone this wiki locally