RE: Perform streaming logical transactions by background workers and parallel apply
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
Dear Wang,
Followings are my comments about v23-0003. Currently I do not have any comments about 0002 and 0004.
09. general
It seems that logicalrep_rel_mark_parallel_apply() is always called when relations are opened on the subscriber-side,
but is it really needed? There checks are required only for streaming parallel apply,
so it may be not needed in case of streaming = 'on' or 'off'.
10. commit message
2) There cannot be any non-immutable functions used by the subscriber-side
replicated table. Look for functions in the following places:
* a. Trigger functions
* b. Column default value expressions and domain constraints
* c. Constraint expressions
* d. Foreign keys
"Foreign key" should not be listed here because it is not related with the mutability. I think it should be listed as 3), not d..
11. create_subscription.sgml
The constraint about foreign key should be described here.
11. relation.c
11.a
+ CacheRegisterSyscacheCallback(PROCOID,
+ logicalrep_relmap_reset_parallel_cb,
+ (Datum) 0);
Isn't it needed another syscache callback for pg_type?
Users can add any constraints via ALTER DOMAIN command, but the added constraint may be not checked.
I checked AlterDomainAddConstraint(), and it invalidates only the relcache for pg_type.
11.b
+ /*
+ * If the column is of a DOMAIN type, determine whether
+ * that domain has any CHECK expressions that are not
+ * immutable.
+ */
+ if (get_typtype(att->atttypid) == TYPTYPE_DOMAIN)
+ {
I think the default value of *domain* must be also checked here.
I tested like followings.
===
1. created a domain that has a default value
CREATE DOMAIN tmp INT DEFAULT 1 CHECK (VALUE > 0);
2. created a table
CREATE TABLE foo (id tmp PRIMARY KEY);
3. checked pg_attribute and pg_class
select oid, relname, attname, atthasdef from pg_attribute, pg_class where pg_attribute.attrelid = pg_class.oid and pg_class.relname = 'foo' and attname = 'id';
oid | relname | attname | atthasdef
-------+---------+---------+-----------
16394 | foo | id | f
(1 row)
Tt meant that functions might be not checked because the if-statement `if (att->atthasdef)` became false.
===
12. 015_stream.pl, 016_stream_subxact.pl, 022_twophase_cascade.pl, 023_twophase_stream.pl
- my ($node_publisher, $node_subscriber, $appname, $is_parallel) = @_;
+ my ($node_publisher, $node_subscriber, $appname) = @_;
Why the parameter is removed? I think the test that waits the output
from the apply background worker is meaningful.
13. 032_streaming_apply.pl
The filename seems too general because apply background workers are tested in above tests.
How about "streaming_apply_constraint" or something?
Best Regards,
Hayato Kuroda
FUJITSU LIMITED
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix invalid memory access during the shutdown of the parallel apply worker.
- 3d144c6c8602 16.0 landed
-
Fix assertion failure in apply worker.
- de63f8dadee4 16.0 landed
-
Use elog to report unexpected action in handle_streamed_transaction().
- 781ac42d43ab 16.0 landed
-
Use appropriate wait event when sending data in the apply worker.
- d9d7fe68d35e 16.0 landed
-
Allow the logical_replication_mode to be used on the subscriber.
- 9f2213a7c575 16.0 landed
-
Rename GUC logical_decoding_mode to logical_replication_mode.
- 1e8b61735cfb 16.0 landed
-
Display the leader apply worker's PID for parallel apply workers.
- d540a02a724b 16.0 landed
-
Improve the code to decide and process the apply action.
- c981d9145dea 16.0 landed
-
Document the newly added wait events added by commit 216a784829.
- cd06ccd78fcf 16.0 landed
-
Perform apply of large transactions by parallel workers.
- 216a784829c2 16.0 landed
-
Wake up a subscription's replication worker processes after DDL.
- c6e1f62e2cee 16.0 cited
-
Add copyright notices to meson files
- 8284cf5f746f 16.0 cited
-
Better document logical replication parameters
- a8500750ca0a 16.0 cited
-
Add a common function to generate the origin name.
- 776e1c8a5d14 16.0 cited
-
Harmonize parameter names in storage and AM code.
- bfcf1b34805f 16.0 cited
-
Avoid using list_length() to test for empty list.
- efd0c16becbf 16.0 cited
-
Improve two comments related to a boolean DefElem's value
- 8445f5a21d40 16.0 cited
-
Fix partition table's REPLICA IDENTITY checking on the subscriber.
- 26b3455afaa9 15.0 cited
-
Fix data inconsistency between publisher and subscriber.
- b7658c24c7c1 15.0 cited
-
Fix cache look-up failures while applying changes in logical replication.
- 5a97b1325453 15.0 cited