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

Commit28a8cc4

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 parent5e85bc3 commit28a8cc4

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
@@ -120,7 +120,14 @@
120120
#include"utils/snapmgr.h"
121121
#include"utils/syscache.h"
122122

123-
staticbooltable_states_valid= false;
123+
typedefenum
124+
{
125+
SYNC_TABLE_STATE_NEEDS_REBUILD,
126+
SYNC_TABLE_STATE_REBUILD_STARTED,
127+
SYNC_TABLE_STATE_VALID,
128+
}SyncingTablesState;
129+
130+
staticSyncingTablesStatetable_states_validity=SYNC_TABLE_STATE_NEEDS_REBUILD;
124131
staticList*table_states_not_ready=NIL;
125132
staticboolFetchTableStates(bool*started_tx);
126133

@@ -270,7 +277,7 @@ wait_for_worker_state_change(char expected_state)
270277
void
271278
invalidate_syncing_table_states(Datumarg,intcacheid,uint32hashvalue)
272279
{
273-
table_states_valid=false;
280+
table_states_validity=SYNC_TABLE_STATE_NEEDS_REBUILD;
274281
}
275282

276283
/*
@@ -1465,13 +1472,15 @@ FetchTableStates(bool *started_tx)
14651472

14661473
*started_tx= false;
14671474

1468-
if (!table_states_valid)
1475+
if (table_states_validity!=SYNC_TABLE_STATE_VALID)
14691476
{
14701477
MemoryContextoldctx;
14711478
List*rstates;
14721479
ListCell*lc;
14731480
SubscriptionRelState*rstate;
14741481

1482+
table_states_validity=SYNC_TABLE_STATE_REBUILD_STARTED;
1483+
14751484
/* Clean the old lists. */
14761485
list_free_deep(table_states_not_ready);
14771486
table_states_not_ready=NIL;
@@ -1505,7 +1514,15 @@ FetchTableStates(bool *started_tx)
15051514
has_subrels= (list_length(table_states_not_ready)>0)||
15061515
HasSubscriptionRelations(MySubscription->oid);
15071516

1508-
table_states_valid= true;
1517+
/*
1518+
* If the subscription relation cache has been invalidated since we
1519+
* entered this routine, we still use and return the relations we just
1520+
* finished constructing, to avoid infinite loops, but we leave the
1521+
* table states marked as stale so that we'll rebuild it again on next
1522+
* access. Otherwise, we mark the table states as valid.
1523+
*/
1524+
if (table_states_validity==SYNC_TABLE_STATE_REBUILD_STARTED)
1525+
table_states_validity=SYNC_TABLE_STATE_VALID;
15091526
}
15101527

15111528
returnhas_subrels;

‎src/tools/pgindent/typedefs.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,6 +2635,7 @@ SupportRequestSelectivity
26352635
SupportRequestSimplify
26362636
SupportRequestWFuncMonotonic
26372637
Syn
2638+
SyncingTablesState
26382639
SyncOps
26392640
SyncRepConfigData
26402641
SyncRepStandbyData

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp