Fix custom schema support of rivertest.Worker#1262
Conversation
brandur
left a comment
There was a problem hiding this comment.
Great, thank you!!
A couple minor nits below. Could you also add a changelog entry under the "fixed" section please?
| // is migrated into an isolated named schema and worked through a transaction | ||
| // whose search_path is empty (see DBPool), so its tables resolve only via | ||
| // schema qualification. | ||
| func TestWorker_Work_CustomSchema(t *testing.T) { |
There was a problem hiding this comment.
The tests are currently ordered as:
TestWorker_WorkTestWorker_WorkJob
With subtests under each for different things. It seems a bit odd to pull out this new responsibility into a separate top-level test and put Work + WorkJob under it.
Can you ask Claude to reorder so that "CustomSchema" becomes a subtest under each of TestWorker_Work and TestWorker_WorkJob instead?
There was a problem hiding this comment.
I greenlighted a separate test because these need a different setup, but yeah, probably better to fold in with inline setup instead. Done.
3c7426c to
044cda2
Compare
|
@zmwangx Thanks! And can you add that changelog too? |
…Worker`
`rivertest.Worker` works a job in three database steps: it inserts the job
through the client, builds an inline completer, and transitions the job to
`running` via `JobUpdateFull`. The first two already thread `config.Schema`
through — the client uses it internally, and it's passed explicitly to
`jobcompleter.NewInlineCompleter` — but the `JobUpdateFull` call omitted it.
With a non-default `Schema`, the insert lands the job in `<schema>.river_job`
correctly, then the running-state update runs unqualified and resolves only
through the connection's `search_path`. On a connection that doesn't include
the configured schema it fails one step later with:
test worker internal error: failed to update job to running state: ERROR: relation "river_job" does not exist (SQLSTATE 42P01)
Pass `w.config.Schema` into `JobUpdateFullParams` so all three steps agree on
the schema. This finishes custom-schema support for `rivertest.Worker`; the
`rivertest.Require*` family received an analogous per-call `Schema` option in
riverqueue#926 (riverqueue#907).
The regression tests migrate River into an isolated named schema and work jobs
through a transaction whose `search_path` is empty, so the tables resolve only
via schema qualification — the exact condition that fails before this change.
They live as `CustomSchema` subtests of `TestWorker_Work` and
`TestWorker_WorkJob`, each building its own bundle inline since the schema setup
differs from those tests' shared `setup`.
044cda2 to
3134739
Compare
|
Oh sorry, missed that comment. Pushed. |
Currently,
rivertest.Workerignores custom schema in river config.The fix is one line. Also added a test case for it.
Simple testcontainers-based repro:
Disclosure: Claude Opus assisted in authoring the fix. Everything's carefully human reviewed, and PR is entirely human authored.