Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pglogical.wait_slot_confirm_lsn docs are incorrect #481

Open
jcoleman opened this issue Jul 24, 2024 · 1 comment
Open

pglogical.wait_slot_confirm_lsn docs are incorrect #481

jcoleman opened this issue Jul 24, 2024 · 1 comment

Comments

@jcoleman
Copy link

The docs for pglogical.wait_slot_confirm_lsn say:

Wait until all replication slots on the current node have replayed up to the xlog insert position at time of call on all providers. Returns when all slots' confirmed_flush_lsn passes the pg_current_wal_insert_lsn() at time of call.

but looking at the code that's not what actually happens:

	if (PG_ARGISNULL(1))
	{
		if (XLogRecPtrIsInvalid(XactLastCommitEnd))
			target_lsn = GetXLogInsertRecPtr();
		else
			target_lsn = XactLastCommitEnd;
	}

Contra the docs we use the LSN for the last commit performed on the current backend (if one is available). That means that it's possible for the following scenario to occur:

  1. Worker A: COMMIT (lsn 123); confirmed_flush_lsn = 0
  2. Worker B: COMMIT (lsn 456); confirmed_flush_lsn = 123
  3. Worker A: wait_slot_confirm_lsn(slot, NULL => turned into last commit at 123); confirmed_flush_lsn = 123
  4. Worker A: wait_slot_confirm_lsn returns
  5. COMMIT (lsn 456) replicates
@jcoleman
Copy link
Author

BTW the behavior here diverged from the documented behavior in b72a618 which sadly has no context in the commit message other than the fact that this was backported from pglogical3, so presumably there was an intentional reason to change this in v3, but there's no information as to why that's desirable, and the docs certainly weren't changed to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant