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

Commit7c8345f

Browse files
committed
Correctly align page's images in generic wal API
Page image should be MAXALIGN'ed because existing code could directly alignpointers in page instead of align offset from beginning of page.Found during play with indexes as extenstion, Alexander Korotkov and me
1 parent02a568a commit7c8345f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎src/backend/access/transam/generic_xlog.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ typedef struct
5252
Bufferbuffer;/* registered buffer */
5353
intflags;/* flags for this buffer */
5454
intdeltaLen;/* space consumed in delta field */
55-
charimage[BLCKSZ];/* copy of page image for modification */
55+
char*image;/* copy of page image for modification,
56+
* do not do it in-place to have aligned
57+
* memory chunk */
5658
chardelta[MAX_DELTA_SIZE];/* delta between page images */
5759
}PageData;
5860

@@ -268,7 +270,15 @@ GenericXLogStart(Relation relation)
268270

269271
state->isLogged=RelationNeedsWAL(relation);
270272
for (i=0;i<MAX_GENERIC_XLOG_PAGES;i++)
273+
{
274+
/*
275+
* pre-alloc page's images to prevent allocation in
276+
* GenericXLogRegisterBuffer() which could be called in different
277+
* memory context(s)
278+
*/
279+
state->pages[i].image=palloc(BLCKSZ);
271280
state->pages[i].buffer=InvalidBuffer;
281+
}
272282

273283
returnstate;
274284
}
@@ -422,6 +432,8 @@ GenericXLogFinish(GenericXLogState *state)
422432
lsn=InvalidXLogRecPtr;
423433
}
424434

435+
for (i=0;i<MAX_GENERIC_XLOG_PAGES;i++)
436+
pfree(state->pages[i].image);
425437
pfree(state);
426438

427439
returnlsn;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp