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

Commit38a4a53

Browse files
committed
Fix double shared memory allocation.
SLRU buffer lwlocks are allocated twice by oversight in commitfe702a7 where that locks were moved toseparate tranche. The bug doesn't have user-visible effects except smalloverspending of shared memory.Backpatch to 9.6 where it was introduced.Alexander Korotkov with small editorization by me.
1 parent5512427 commit38a4a53

File tree

1 file changed

+7
-3
lines changed
  • src/backend/access/transam

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,16 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
204204
shared->page_lru_count= (int*) (ptr+offset);
205205
offset+=MAXALIGN(nslots*sizeof(int));
206206

207+
/* Initialize LWLocks */
208+
shared->buffer_locks= (LWLockPadded*) (ptr+offset);
209+
offset+=MAXALIGN(nslots*sizeof(LWLockPadded));
210+
207211
if (nlsns>0)
208212
{
209213
shared->group_lsn= (XLogRecPtr*) (ptr+offset);
210214
offset+=MAXALIGN(nslots*nlsns*sizeof(XLogRecPtr));
211215
}
212216

213-
/* Initialize LWLocks */
214-
shared->buffer_locks= (LWLockPadded*)ShmemAlloc(sizeof(LWLockPadded)*nslots);
215-
216217
Assert(strlen(name)+1<SLRU_MAX_NAME_LENGTH);
217218
strlcpy(shared->lwlock_tranche_name,name,SLRU_MAX_NAME_LENGTH);
218219
shared->lwlock_tranche_id=tranche_id;
@@ -232,6 +233,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
232233
shared->page_lru_count[slotno]=0;
233234
ptr+=BLCKSZ;
234235
}
236+
237+
/* Should fit to estimated shmem size */
238+
Assert(ptr- (char*)shared <=SimpleLruShmemSize(nslots,nlsns));
235239
}
236240
else
237241
Assert(found);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp