mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-18 18:54:34 +08:00
Worker processes inherit the open libpq socket of the converter's
source DB connection. When a worker exits, the pg gem's cleanup sends
a libpq Terminate message over that shared socket and the server
closes the session — the main process would lose its connection right
after the first parallel step ("server closed the connection
unexpectedly"). No step runs in parallel on main yet, so this plugs
the hole before one does.
Workers now redirect the inherited socket to /dev/null right after the
fork (the same trick as ActiveRecord's discard!) and drop the
connection object. Using the adapter in a worker afterwards raises
DiscardedError instead of silently corrupting the shared socket.
Note on ForkManager: #40816 removed the then-unused after_fork_child
API. That version was one-shot job-setup machinery (hardwired
run_once, cleared after the first fork batch) and was superseded by
the explicit Worker -> job.setup lifecycle. This change reintroduces
the name with different semantics: a persistent, removable hook
alongside before_fork and after_fork_parent, registered by the
resource that owns the connection — the same role the parent-side
hooks already play for the SQLite connection.
|
||
|---|---|---|
| .. | ||
| lib | ||
| spec | ||
| .rspec | ||
| Gemfile | ||
| migrations-converters.gemspec | ||