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

Commitb553037

Browse files
committed
Fix rare sharedtuplestore.c corruption.
If the final chunk of an oversized tuple being written out to disk wasexactly 32760 bytes, it would be corrupted due to a fencepost bug.Bug #17619. Back-patch to 11 where the code arrived.While testing that (see test module in archives), I (tmunro) noticedthat the per-participant page counter was not initialized to zero as itshould have been; that wasn't a live bug when it was written since DSMmemory was originally always zeroed, but since 14min_dynamic_shared_memory might be configured and it supplies non-zeroedmemory, so that is also fixed here.Author: Dmitry Astapov <dastapov@gmail.com>Discussion:https://postgr.es/m/17619-0de62ceda812b8b5%40postgresql.org
1 parent92fc127 commitb553037

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎src/backend/utils/sort/sharedtuplestore.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ sts_initialize(SharedTuplestore *sts, int participants,
160160
LWLockInitialize(&sts->participants[i].lock,
161161
LWTRANCHE_SHARED_TUPLESTORE);
162162
sts->participants[i].read_page=0;
163+
sts->participants[i].npages=0;
163164
sts->participants[i].writing= false;
164165
}
165166

@@ -321,7 +322,7 @@ sts_puttuple(SharedTuplestoreAccessor *accessor, void *meta_data,
321322

322323
/* Do we have space? */
323324
size=accessor->sts->meta_data_size+tuple->t_len;
324-
if (accessor->write_pointer+size >=accessor->write_end)
325+
if (accessor->write_pointer+size>accessor->write_end)
325326
{
326327
if (accessor->write_chunk==NULL)
327328
{
@@ -341,7 +342,7 @@ sts_puttuple(SharedTuplestoreAccessor *accessor, void *meta_data,
341342
}
342343

343344
/* It may still not be enough in the case of a gigantic tuple. */
344-
if (accessor->write_pointer+size >=accessor->write_end)
345+
if (accessor->write_pointer+size>accessor->write_end)
345346
{
346347
size_twritten;
347348

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp