Hi Hou,
> I agree that we cannot catch all possible errors. After thinking about this
> more, there are other errors—such as deadlock timeout or lock timeout—that
> cannot easily be pre-checked, so adding an error context looks like a good
> approach to me. Attached is a patch that adds the error context as
> suggested.
Thanks for the patch. I initially felt that setting/reseting the error context
can be in the copy_sequence(), but yours seem to slightly better.
get_and_validate_seq_info() may report another error.
One comment for the test: below lines may not be needed, because REFRESH
SEQUENCES
does not require apply workers, and the launcher eventually starts workers with
the appropriate owner. Doesn't upcoming wait_for_log() enough?
```
# Wait until the apply worker has started under the new subscription owner.
$node_subscriber->poll_query_until('postgres',
"SELECT count(1) = 1 FROM pg_stat_subscription s JOIN pg_stat_activity
a USING (pid) WHERE s.subname = 'regress_seq_sub' AND s.worker_type = 'apply'
AND a.usename = 'regress_seq_sub_owner'"
) or die "Timed out while waiting for apply worker to start as new owner";
```
Best regards,
Hayato Kuroda
FUJITSU LIMITED