feat: add REPLICA IDENTITY NOTHING / USING INDEX support#91
Open
osmanok wants to merge 4 commits intoTrendyol:mainfrom
Open
feat: add REPLICA IDENTITY NOTHING / USING INDEX support#91osmanok wants to merge 4 commits intoTrendyol:mainfrom
osmanok wants to merge 4 commits intoTrendyol:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This MR adds full support for PostgreSQL replica identity modes
NOTHINGandUSING INDEX, in addition to existingDEFAULTandFULL.The change includes config support, validation, SQL execution changes, reconciliation/diff improvements, docs, and tests.
Background
Before this MR, table-level replica identity configuration supported only
DEFAULTandFULL.Issue #49 asks for support for the remaining PostgreSQL modes:
NOTHINGUSING INDEXThese modes are important for workloads that want to reduce old-row payload size and use index-based key tuples for update/delete replication messages.
What Changed
1) Config model and validation
ReplicaIdentityIndextopublication.Table.NOTHINGandUSING INDEX.ReplicaIdentityIndexis required when identity isUSING INDEX.ReplicaIdentityIndexmust be empty for all other identity modes.2) Replica identity execution and reconciliation
relreplidentcodes:d,f,n,i.AlterTableReplicaIdentity(...)to:REPLICA IDENTITY USING INDEX <index>forUSING INDEXGetReplicaIdentities(...)to fetch both:relreplident)pg_index.indisreplidentjoin)ReplicaIdentityIndex.3) Operational safety/logging
NOTHINGwhile publication operations includeUPDATEorDELETE.Operations.Contains(...)helper used by the warning check.4) Documentation updates
DEFAULT,FULL,NOTHING,USING INDEXpublication.tables[i].replicaIdentityIndexfieldFULL-> old tuple data (O)USING INDEX-> key tuple data (K)Behavior Matrix
DEFAULTFULLO)NOTHINGUSING INDEXK)Test Coverage
Unit tests
pq/publication/table_test.goReplicaIdentityIndexrulespq/publication/replica_identity_test.god/f/n/i)Integration tests
Updated
integration_test/system_identity_full_test.gowith:TestReplicaIdentityNothingTestReplicaIdentityUsingIndexTestReplicaIdentityUsingIndexUpdateUsesKeyTupleTestReplicaIdentityUsingIndexMissingIndexReturnsErrorBackward Compatibility
DEFAULTandFULLconfigurations.USING INDEXnow fail early with explicit errors.Risk Assessment
USING INDEXrelies on valid PostgreSQL index constraints; invalid/missing index cases are covered with integration tests.NOTHINGwith UPDATE/DELETE is allowed by design but now emits warning logs to make the trade-off explicit.