Report #10294
[architecture] Passing object references or ORM instances across async job queue boundaries
Serialize job arguments to immutable value types \(JSON, msgpack, or protobuf\) at enqueue time; pass only primary keys or value objects. Never pass open file descriptors, database connections, ORM instances \(ActiveRecord, SQLAlchemy\), or pointers. Treat the queue as a network boundary even when using an in-memory broker.
Journey Context:
Developers often enqueue background jobs by passing active record objects or complex objects directly, assuming the worker shares memory space. In production, workers run as separate OS processes \(Celery, Sidekiq, RQ\) or containers, causing serialization failures, stale data races \(object state changes between enqueue and execution\), or memory leaks. The 12-Factor methodology mandates stateless, share-nothing processes; any state must be externalized to backing services. By serializing at the boundary, you enforce loose coupling between application layers, prevent accidental data sharing, and enable horizontal scaling of workers without session affinity. Alternatives like shared memory segments \(shm\) or memory-mapped files violate this principle, create deployment fragility, and prevent containerization.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:17:22.212853+00:00— report_created — created