| From: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
|---|---|
| To: | 'Ajin Cherian' <itsajin(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | RE: Wrong relation in apply worker "not updatable" errors PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>for partitions; relcache leak in check_and_init_gencol() |
| Date: | 2026-12-04 09:10:09 |
| Message-ID: | OS7PR01MB18317840AE3392D32DECCC3BFF54A2@OS7PR01MB18317.jpnprd01.prod.outlook.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
> I don't think the two lines need to name the same relation, because
> they report different things. The CONTEXT describes the change as it
> arrived: it is set from the map entry of the relation named in the
> replication message, before tuple routing picks a partition. The ERROR
> reports the relation that failed the check, which for a routed change
> is the leaf partition. Both are subscriber relations, so "target" fits
> both.
>
> This is also what the apply worker already does elsewhere for routed
> changes. Conflict reports name the leaf partition while the CONTEXT
> names the replicated table; for example, 013_partition.pl checks for
> 'conflict detected on relation "public.tab1_2_2"', and tab1_2_2 exists
> only on the subscriber. CheckSubscriptionTargetRel() also reports the
> leaf partition. With 0001, check_relation_updatable() behaves the same
> way.
Thanks for the detailed description. I have never considered the theory and you
sound right.
One small comment:
```
+$node_subscriber2->wait_for_log(
+ qr/ERROR: ( [A-Z0-9]+:)? logical replication target relation "[^"]+" has neither REPLICA IDENTITY index nor PRIMARY KEY/,
+ $log_location);
+
+$logfile = slurp_file($node_subscriber2->logfile(), $log_location);
+like(
+ $logfile,
+ qr/logical replication target relation "public.tab5_1" has neither REPLICA IDENTITY index nor PRIMARY KEY/,
+ 'error names the leaf partition that has no replica identity');
```
This looks redundant because similar lines appear twice at near place.
How about using an error pattern and extract the relation's name? It's clearer
where is a problem.
(might be matter of taste)
```
my $err_pattern =
qr/ERROR: (?: [A-Z0-9]+:)? logical replication target relation "([^"]+)" has neither REPLICA IDENTITY index nor PRIMARY KEY/;
$node_subscriber2->wait_for_log($err_pattern, $log_location);
$logfile = slurp_file($node_subscriber2->logfile(), $log_location);
my ($reported_relation) = $logfile =~ $err_pattern;
is($reported_relation, 'public.tab5_1',
'error names the leaf partition that has no replica identity');
```
Best regards,
Hayato Kuroda
FUJITSU LIMITED
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kirill Reshke | 2026-12-04 09:11:44 | Re: several cases of float and integer mixup |
| Previous Message | Zsolt Parragi | 2026-12-04 09:06:57 | Re: DROP USER MAPPING doesn't acquire lock on its server |