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

Commit7e1fb4c

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 parent68f785f commit7e1fb4c

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
@@ -205,15 +205,16 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
205205
shared->page_lru_count= (int*) (ptr+offset);
206206
offset+=MAXALIGN(nslots*sizeof(int));
207207

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

214-
/* Initialize LWLocks */
215-
shared->buffer_locks= (LWLockPadded*)ShmemAlloc(sizeof(LWLockPadded)*nslots);
216-
217218
Assert(strlen(name)+1<SLRU_MAX_NAME_LENGTH);
218219
strlcpy(shared->lwlock_tranche_name,name,SLRU_MAX_NAME_LENGTH);
219220
shared->lwlock_tranche_id=tranche_id;
@@ -230,6 +231,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
230231
shared->page_lru_count[slotno]=0;
231232
ptr+=BLCKSZ;
232233
}
234+
235+
/* Should fit to estimated shmem size */
236+
Assert(ptr- (char*)shared <=SimpleLruShmemSize(nslots,nlsns));
233237
}
234238
else
235239
Assert(found);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp