How does pglogical.replicate_ddl_command ensure that ddls are run at a consistent point?

320 Views Asked by At

From the pglogical readme:

pglogical provides the pglogical.replicate_ddl_command function to allow DDL to be run on the provider and subscriber at a consistent point.

But how exactly does it ensure that that happens?

Looking through the codebase, I see that in pglogical_replicate_ddl_command they queue the command for replication:

/* Queue the query for replication. */
    queue_message(replication_sets, GetUserId(),
                  QUEUE_COMMAND_TYPE_SQL, cmd.data);

which then gets replicated as part of the ddl_sql replication set.

Upon receiving this sql string, the query gets extracted by handle_sql and then run by pglogical_execute_sql_command.

But I don't see anywhere where they ensure that all previous data has been replicated, such that we are at a consistent point.. what am I missing here?

0

There are 0 best solutions below