Don't crash-loop the apply worker on a schema-mismatched column - #619
Conversation
Add a scheduled TAP test that creates a genuine schema mismatch: the provider table has a column that is absent from the subscriber. Replicating a row from that table reproduces an error while spock_relation_open() builds the remote-to-local attribute map, before row-level exception handling is entered. Without the fix, exception replay raises the same error, restarts the apply worker at the unadvanced origin LSN, and prevents later transactions from replicating. Verify that the offending transaction is logged and discarded, the subscription remains healthy, repeated mismatches do not cause a retry storm, and unrelated transactions continue to replicate.
spock_relation_open() raised a bare elog(ERROR) for a remote column missing locally, before the per-row exception-handling subtransaction is ever entered, so spock.exception_behaviour never applied and the same error kept re-throwing on every replay, restarting the worker forever. tupdesc_get_att_by_name() now returns -1 for a missing column instead of erroring, and spock_relation_open() handles that the same way it already handles an unresolvable relation: raise on the first attempt, but return NULL during replay so the caller discards and logs the action through the normal exception path.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
spock_relation_open() stopped at the first column the local relation lacks, so repairing a drifted schema meant fixing one column, hitting the same error, and repeating. Collect them all and report once. The wording for a single missing column is unchanged, so existing tests still match. Also close with NoLock on that path, matching every other apply-path close: the lock is held until the replication transaction ends rather than being dropped on a table we are part way through.
Don't crash-loop the apply worker on a schema-mismatched column
spock_relation_open() raised a bare elog(ERROR) for a remote column
missing locally, before the per-row exception-handling subtransaction
is ever entered, so spock.exception_behaviour never applied and the
same error kept re-throwing on every replay, restarting the worker
forever.
tupdesc_get_att_by_name() now returns -1 for a missing column instead
of erroring, and spock_relation_open() handles that the same way it
already handles an unresolvable relation: raise on the first attempt,
but return NULL during replay so the caller discards and logs the
action through the normal exception path.