Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa79bde

Browse files
author
Amit Kapila
committed
Fix the missing table sync due to improper invalidation handling.
We missed performing table sync if the invalidation happened while thenon-ready tables list was being prepared. This occurs because the syncstate was set to valid at the end of non-ready table list preparationirrespective of the invalidations processed while the list is beingprepared.Fix it by changing the boolean variable to a tri-state enum and by settingtable state to valid only if no invalidations have occurred while the listis being prepared.Reprted-by: Alexander LakhinDiagnosed-by: Alexander LakhinAuthor: Vignesh CReviewed-by: Hou Zhijie, Alexander Lakhin, Ajin Cherian, Amit KapilaBackpatch-through: 15Discussion:https://postgr.es/m/711a6afe-edb7-1211-cc27-1bef8239eec7@gmail.com
1 parentee3ef4a commitaa79bde

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

‎src/backend/replication/logical/tablesync.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@
123123
#include"utils/syscache.h"
124124
#include"utils/usercontext.h"
125125

126-
staticbooltable_states_valid= false;
126+
typedefenum
127+
{
128+
SYNC_TABLE_STATE_NEEDS_REBUILD,
129+
SYNC_TABLE_STATE_REBUILD_STARTED,
130+
SYNC_TABLE_STATE_VALID,
131+
}SyncingTablesState;
132+
133+
staticSyncingTablesStatetable_states_validity=SYNC_TABLE_STATE_NEEDS_REBUILD;
127134
staticList*table_states_not_ready=NIL;
128135
staticboolFetchTableStates(bool*started_tx);
129136

@@ -273,7 +280,7 @@ wait_for_worker_state_change(char expected_state)
273280
void
274281
invalidate_syncing_table_states(Datumarg,intcacheid,uint32hashvalue)
275282
{
276-
table_states_valid=false;
283+
table_states_validity=SYNC_TABLE_STATE_NEEDS_REBUILD;
277284
}
278285

279286
/*
@@ -1568,13 +1575,15 @@ FetchTableStates(bool *started_tx)
15681575

15691576
*started_tx= false;
15701577

1571-
if (!table_states_valid)
1578+
if (table_states_validity!=SYNC_TABLE_STATE_VALID)
15721579
{
15731580
MemoryContextoldctx;
15741581
List*rstates;
15751582
ListCell*lc;
15761583
SubscriptionRelState*rstate;
15771584

1585+
table_states_validity=SYNC_TABLE_STATE_REBUILD_STARTED;
1586+
15781587
/* Clean the old lists. */
15791588
list_free_deep(table_states_not_ready);
15801589
table_states_not_ready=NIL;
@@ -1608,7 +1617,15 @@ FetchTableStates(bool *started_tx)
16081617
has_subrels= (table_states_not_ready!=NIL)||
16091618
HasSubscriptionRelations(MySubscription->oid);
16101619

1611-
table_states_valid= true;
1620+
/*
1621+
* If the subscription relation cache has been invalidated since we
1622+
* entered this routine, we still use and return the relations we just
1623+
* finished constructing, to avoid infinite loops, but we leave the
1624+
* table states marked as stale so that we'll rebuild it again on next
1625+
* access. Otherwise, we mark the table states as valid.
1626+
*/
1627+
if (table_states_validity==SYNC_TABLE_STATE_REBUILD_STARTED)
1628+
table_states_validity=SYNC_TABLE_STATE_VALID;
16121629
}
16131630

16141631
returnhas_subrels;

‎src/tools/pgindent/typedefs.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,6 +2764,7 @@ SupportRequestSelectivity
27642764
SupportRequestSimplify
27652765
SupportRequestWFuncMonotonic
27662766
Syn
2767+
SyncingTablesState
27672768
SyncOps
27682769
SyncRepConfigData
27692770
SyncRepStandbyData

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp