8000 Add interrupt checks to contrib/pg_prewarm. · postgres/postgres@57b2e10 · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"commit":{"oid":"57b2e1049e7fdb0ca7882c74520e409507462eb2","url":"/postgres/postgres/commit/57b2e1049e7fdb0ca7882c74520e409507462eb2","authoredDate":"2014-11-12T18:52:49.000+01:00","committedDate":"2014-11-12T21:06:32.000+01:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eAdd interrupt checks to contrib/pg_prewarm.\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"Currently the extension's pg_prewarm() function didn't check\ninterrupts once it started \"warming\" data. Since individual calls can\ntake a long while it's important for them to be interruptible.\n\nBackpatch to 9.4 where pg_prewarm was introduced.","authors":[{"login":"anarazel","displayName":"Andres Freund","avatarUrl":"https://avatars.githubusercontent.com/u/1598211?v=4","path":"/anarazel","isGitHub":false}],"committerAttribution":false,"committer":{"login":"anarazel","displayName":"Andres Freund","avatarUrl":"https://avatars.githubusercontent.com/u/1598211?v=4","path":"/anarazel","isGitHub":false},"parents":["c4d360d18259690442036c1ee07a899cbe4022a0"],"globalRelayId":"MDY6Q29tbWl0OTI3NDQyOjU3YjJlMTA0OWU3ZmRiMGNhNzg4MmM3NDUyMGU0MDk1MDc0NjJlYjI=","sha1":"c4d360d18259690442036c1ee07a899cbe4022a0","sha2":"57b2e1049e7fdb0ca7882c74520e409507462eb2"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":158,"text":"@@ -159,6 +159,7 @@ pg_prewarm(PG_FUNCTION_ARGS)","html":"@@ -159,6 +159,7 @@ pg_prewarm(PG_FUNCTION_ARGS)","displayNoNewLineWarning":false,"position":0,"left":158,"right":158},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":159,"text":" \t\t */","html":" \u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":159,"right":159},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":160,"text":" \t\tfor (block = first_block; block \u003c= last_block; ++block)","html":" \t\t\u003cspan class=pl-k\u003efor\u003c/span\u003e (\u003cspan class=pl-s1\u003eblock\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003efirst_block\u003c/span\u003e; \u003cspan class=pl-s1\u003eblock\u003c/span\u003e \u0026lt;= \u003cspan class=pl-s1\u003elast_block\u003c/span\u003e; \u003cspan class=pl-c1\u003e++\u003c/span\u003e\u003cspan class=pl-s1\u003eblock\u003c/span\u003e)","displayNoNewLineWarning":false,"position":2,"left":160,"right":160},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":161,"text":" \t\t{","html":" \t\t{","displayNoNewLineWarning":false,"position":3,"left":161,"right":161},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":162,"text":"+\t\t\tCHECK_FOR_INTERRUPTS();","html":"+\t\t\t\u003cspan class=pl-en\u003eCHECK_FOR_INTERRUPTS\u003c/span\u003e();","displayNoNewLineWarning":false,"position":4,"left":161,"right":162},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":163,"text":" \t\t\tPrefetchBuffer(rel, forkNumber, block);","html":" \t\t\t\u003cspan class=pl-en\u003ePrefetchBuffer\u003c/span\u003e(\u003cspan class=pl-s1\u003erel\u003c/span\u003e, \u003cspan class=pl-s1\u003eforkNumber\u003c/span\u003e, \u003cspan class=pl-s1\u003eblock\u003c/span\u003e);","displayNoNewLineWarning":false,"position":5,"left":162,"right":163},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":164,"text":" \t\t\t++blocks_done;","html":" \t\t\t\u003cspan class=pl-c1\u003e++\u003c/span\u003e\u003cspan class=pl-s1\u003eblocks_done\u003c/span\u003e;","displayNoNewLineWarning":false,"position":6,"left":163,"right":164},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":165,"text":" \t\t}","html":" \t\t}","displayNoNewLineWarning":false,"position":7,"left":164,"right":165},{"stylingDirective":null,"type":"HUNK","blobLineNumber":177,"text":"@@ -177,6 +178,7 @@ pg_prewarm(PG_FUNCTION_ARGS)","html":"@@ -177,6 +178,7 @@ pg_prewarm(PG_FUNCTION_ARGS)","displayNoNewLineWarning":false,"position":8,"left":176,"right":177},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":178,"text":" \t\t */","html":" \u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":9,"left":177,"right":178},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":179,"text":" \t\tfor (block = first_block; block \u003c= last_block; ++block)","html":" \t\t\u003cspan class=pl-k\u003efor\u003c/span\u003e (\u003cspan class=pl-s1\u003eblock\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003efirst_block\u003c/span\u003e; \u003cspan class=pl-s1\u003eblock\u003c/span\u003e \u0026lt;= \u003cspan class=pl-s1\u003elast_block\u003c/span\u003e; \u003cspan class=pl-c1\u003e++\u003c/span\u003e\u003cspan class=pl-s1\u003eblock\u003c/span\u003e)","displayNoNewLineWarning":false,"position":10,"left":178,"right":179},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":180,"text":" \t\t{","html":" \t\t{","displayNoNewLineWarning":false,"position":11,"left":179,"right":180},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":181,"text":"+\t\t\tCHECK_FOR_INTERRUPTS();","html":"+\t\t\t\u003cspan class=pl-en\u003eCHECK_FOR_INTERRUPTS\u003c/span\u003e();","displayNoNewLineWarning":false,"position":12,"left":179,"right":181},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":182,"text":" \t\t\tsmgrread(rel-\u003erd_smgr, forkNumber, block, blockbuffer);","html":" \t\t\t\u003cspan class=pl-en\u003esmgrread\u003c/span\u003e(\u003cspan class=pl-s1\u003erel\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erd_smgr\u003c/span\u003e, \u003cspan class=pl-s1\u003eforkNumber\u003c/span\u003e, \u003cspan class=pl-s1\u003eblock\u003c/span\u003e, \u003cspan class=pl-s1\u003eblockbuffer\u003c/span\u003e);","displayNoNewLineWarning":false,"position":13,"left":180,"right":182},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":183,"text":" \t\t\t++blocks_done;","html":" \t\t\t\u003cspan class=pl-c1\u003e++\u003c/span\u003e\u003cspan class=pl-s1\u003eblocks_done\u003c/span\u003e;","displayNoNewLineWarning":false,"position":14,"left":181,"right":183},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":184,"text":" \t\t}","html":" \t\t}","displayNoNewLineWarning":false,"position":15,"left":182,"right":184},{"stylingDirective":null,"type":"HUNK","blobLineNumber":191,"text":"@@ -190,6 +192,7 @@ pg_prewarm(PG_FUNCTION_ARGS)","html":"@@ -190,6 +192,7 @@ pg_prewarm(PG_FUNCTION_ARGS)","displayNoNewLineWarning":false,"position":16,"left":189,"right":191},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":192,"text":" \t\t{","html":" \t\t{","displayNoNewLineWarning":false,"position":17,"left":190,"right":192},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":193,"text":" \t\t\tBuffer\t\tbuf;","html":" \t\t\t\u003cspan class=pl-smi\u003eBuffer\u003c/span\u003e\t\t\u003cspan class=pl-s1\u003ebuf\u003c/span\u003e;","displayNoNewLineWarning":false,"position":18,"left":191,"right":193},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":194,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":19,"left":192,"right":194},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":195,"text":"+\t\t\tCHECK_FOR_INTERRUPTS();","html":"+\t\t\t\u003cspan class=pl-en\u003eCHECK_FOR_INTERRUPTS\u003c/span\u003e();","displayNoNewLineWarning":false,"position":20,"left":192,"right":195},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":196,"text":" \t\t\tbuf = ReadBufferExtended(rel, forkNumber, block, RBM_NORMAL, NULL);","html":" \t\t\t\u003cspan class=pl-s1\u003ebuf\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eReadBufferExtended\u003c/span\u003e(\u003cspan class=pl-s1\u003erel\u003c/span\u003e, \u003cspan class=pl-s1\u003eforkNumber\u003c/span\u003e, \u003cspan class=pl-s1\u003eblock\u003c/span\u003e, \u003cspan class=pl-c1\u003eRBM_NORMAL\u003c/span\u003e, \u003cspan class=pl-c1\u003eNULL\u003c/span\u003e);","displayNoNewLineWarning":false,"position":21,"left":193,"right":196},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":197,"text":" \t\t\tReleaseBuffer(buf);","html":" \t\t\t\u003cspan class=pl-en\u003eReleaseBuffer\u003c/span\u003e(\u003cspan class=pl-s1\u003ebuf\u003c/span\u003e);","displayNoNewLineWarning":false,"position":22,"left":194,"right":197},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":198,"text":" \t\t\t++blocks_done;","html":" \t\t\t\u003cspan class=pl-c1\u003e++\u003c/span\u003e\u003cspan class=pl-s1\u003eblocks_done\u003c/span\u003e;","displayNoNewLineWarning":false,"position":23,"left":195,"right":198}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":206,"linesChanged":3,"newTreeEntry":{"lineCount":206,"path":"contrib/pg_prewarm/pg_prewarm.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"contrib/pg_prewarm/pg_prewarm.c","mode":100644},"linesAdded":3,"linesDeleted":0,"path":"contrib/pg_prewarm/pg_prewarm.c","pathDigest":"2eaca555ba3d83a7736e971afd152947f3c431d712552e3b8cb998e247e4b181","status":"MODIFIED","truncatedReason":null,"oldOid":"c4d360d18259690442036c1ee07a899cbe4022a0","newOid":"57b2e1049e7fdb0ca7882c74520e409507462eb2","copilotChatReference":null,"deletedSha":"c4d360d18259690442036c1ee07a899cbe4022a0","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/57b2e1049e7fdb0ca7882c74520e409507462eb2","fileTreeExpanded":true,"headerInfo":{"additions":3,"deletions":0,"filesChanged":1,"filesChangedString":"1"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":1,"truncated":false,"byteCount":663,"lineShownCount":24},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"V59j8dvAuP9NjrHtfpQGmXc682aDXKv6fFMVgKuaJtO5-jYoqpHUWW0GQYBWvjFiNWe10LvKbfDQS7qapoHP0Q"},"/users/diffview?diff=unified":{"post":"69sSI1nRTURnawlLGLqirl-7mqbyrmnvwzHJQKgH1AEFvkf6KIAh4kfj-SYwkJVVHebcEMo4r-VvKWZapRw9Aw"},"/notifications/thread":{"post":"Y4s0vVej4pCS_8dkj7pKndrvEBk8-YSGEMAgRp8of1VJKsuXP__4RSekb4JzgVtoLnUxmx59uoIrZX0gMhRn-g"}}},"title":"Add interrupt checks to contrib/pg_prewarm. · postgres/postgres@57b2e10","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}

Commit 57b2e10

Browse files
committed
Add interrupt checks to contrib/pg_prewarm.
Currently the extension's pg_prewarm() function didn't check interrupts once it started "warming" data. Since individual calls can take a long while it's important for them to be interruptible. Backpatch to 9.4 where pg_prewarm was introduced.
1 parent c4d360d commit 57b2e10

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

contrib/pg_prewarm/pg_prewarm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
159159
*/
160160
for (block = first_block; block <= last_block; ++block)
161161
{
162+
CHECK_FOR_INTERRUPTS();
162163
PrefetchBuffer(rel, forkNumber, block);
163164
++blocks_done;
164165
}
@@ -177,6 +178,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
177178
*/
178179
for (block = first_block; block <= last_block; ++block)
179180
{
181+
CHECK_FOR_INTERRUPTS();
180182
smgrread(rel->rd_smgr, forkNumber, block, blockbuffer);
181183
++blocks_done;
182184
}
@@ -190,6 +192,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
190192
{
191193
Buffer buf;
192194

195+
CHECK_FOR_INTERRUPTS();
193196
buf = ReadBufferExtended(rel, forkNumber, block, RBM_NORMAL, NULL);
194197
ReleaseBuffer(buf);
195198
++blocks_done;

0 commit comments

Comments
 (0)
0