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

Commit8270a0d

Browse files
committed
Handle interrupts within a transaction context in REINDEX CONCURRENTLY
Phases 2 (building the new index) and 3 (validating the new index)checked for interrupts outside a transaction context, having asconsequence to not release session-level locks taken on the parentrelation and the old and new indexes processed. This could for examplebe triggered with statement_timeout and a bad timing, and would issueconfusing error messages when shutting down the session still holdingthe locks (note that an assertion failure would be triggered first), ontop of more issues with concurrent sessions trying to take a lock thatwould interfere with the SHARE UPDATE EXCLUSIVE locks hold here.This moves all the interruption checks inside a transaction context.Note that I have manually tested all interruptions to make sure thatinvalid indexes can be cleaned up properly. Partition indexes stillhave issues on their own with some missing dependency handling, whichwill be dealt with in a follow-up patch.Reported-by: Justin PryzbyAuthor: Michael PaquierDiscussion:https://postgr.es/m/20191013025145.GC4475@telsasoft.comBackpatch-through: 12
1 parent3b0c59a commit8270a0d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

‎src/backend/commands/indexcmds.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,11 +3057,16 @@ ReindexRelationConcurrently(Oid relationOid, int options)
30573057
OidnewIndexId=lfirst_oid(lc2);
30583058
OidheapId;
30593059

3060-
CHECK_FOR_INTERRUPTS();
3061-
30623060
/* Start new transaction for this index's concurrent build */
30633061
StartTransactionCommand();
30643062

3063+
/*
3064+
* Check for user-requested abort. This is inside a transaction so as
3065+
* xact.c does not issue a useless WARNING, and ensures that
3066+
* session-level locks are cleaned up on abort.
3067+
*/
3068+
CHECK_FOR_INTERRUPTS();
3069+
30653070
/* Set ActiveSnapshot since functions in the indexes may need it */
30663071
PushActiveSnapshot(GetTransactionSnapshot());
30673072

@@ -3101,10 +3106,15 @@ ReindexRelationConcurrently(Oid relationOid, int options)
31013106
TransactionIdlimitXmin;
31023107
Snapshotsnapshot;
31033108

3104-
CHECK_FOR_INTERRUPTS();
3105-
31063109
StartTransactionCommand();
31073110

3111+
/*
3112+
* Check for user-requested abort. This is inside a transaction so as
3113+
* xact.c does not issue a useless WARNING, and ensures that
3114+
* session-level locks are cleaned up on abort.
3115+
*/
3116+
CHECK_FOR_INTERRUPTS();
3117+
31083118
heapId=IndexGetRelation(newIndexId, false);
31093119

31103120
/*
@@ -3166,6 +3176,11 @@ ReindexRelationConcurrently(Oid relationOid, int options)
31663176
OidnewIndexId=lfirst_oid(lc2);
31673177
OidheapId;
31683178

3179+
/*
3180+
* Check for user-requested abort. This is inside a transaction so as
3181+
* xact.c does not issue a useless WARNING, and ensures that
3182+
* session-level locks are cleaned up on abort.
3183+
*/
31693184
CHECK_FOR_INTERRUPTS();
31703185

31713186
heapId=IndexGetRelation(oldIndexId, false);
@@ -3221,7 +3236,13 @@ ReindexRelationConcurrently(Oid relationOid, int options)
32213236
OidoldIndexId=lfirst_oid(lc);
32223237
OidheapId;
32233238

3239+
/*
3240+
* Check for user-requested abort. This is inside a transaction so as
3241+
* xact.c does not issue a useless WARNING, and ensures that
3242+
* session-level locks are cleaned up on abort.
3243+
*/
32243244
CHECK_FOR_INTERRUPTS();
3245+
32253246
heapId=IndexGetRelation(oldIndexId, false);
32263247
index_concurrently_set_dead(heapId,oldIndexId);
32273248
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp