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

Commita9155ef

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 parentcd0678a commita9155ef

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
@@ -122,7 +122,14 @@
122122
#include"utils/syscache.h"
123123
#include"utils/usercontext.h"
124124

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

@@ -272,7 +279,7 @@ wait_for_worker_state_change(char expected_state)
272279
void
273280
invalidate_syncing_table_states(Datumarg,intcacheid,uint32hashvalue)
274281
{
275-
table_states_valid=false;
282+
table_states_validity=SYNC_TABLE_STATE_NEEDS_REBUILD;
276283
}
277284

278285
/*
@@ -1556,13 +1563,15 @@ FetchTableStates(bool *started_tx)
15561563

15571564
*started_tx= false;
15581565

1559-
if (!table_states_valid)
1566+
if (table_states_validity!=SYNC_TABLE_STATE_VALID)
15601567
{
15611568
MemoryContextoldctx;
15621569
List*rstates;
15631570
ListCell*lc;
15641571
SubscriptionRelState*rstate;
15651572

1573+
table_states_validity=SYNC_TABLE_STATE_REBUILD_STARTED;
1574+
15661575
/* Clean the old lists. */
15671576
list_free_deep(table_states_not_ready);
15681577
table_states_not_ready=NIL;
@@ -1596,7 +1605,15 @@ FetchTableStates(bool *started_tx)
15961605
has_subrels= (table_states_not_ready!=NIL)||
15971606
HasSubscriptionRelations(MySubscription->oid);
15981607

1599-
table_states_valid= true;
1608+
/*
1609+
* If the subscription relation cache has been invalidated since we
1610+
* entered this routine, we still use and return the relations we just
1611+
* finished constructing, to avoid infinite loops, but we leave the
1612+
* table states marked as stale so that we'll rebuild it again on next
1613+
* access. Otherwise, we mark the table states as valid.
1614+
*/
1615+
if (table_states_validity==SYNC_TABLE_STATE_REBUILD_STARTED)
1616+
table_states_validity=SYNC_TABLE_STATE_VALID;
16001617
}
16011618

16021619
returnhas_subrels;

‎src/tools/pgindent/typedefs.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,6 +2676,7 @@ SupportRequestSelectivity
26762676
SupportRequestSimplify
26772677
SupportRequestWFuncMonotonic
26782678
Syn
2679+
SyncingTablesState
26792680
SyncOps
26802681
SyncRepConfigData
26812682
SyncRepStandbyData

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp