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

Commitc7654f6

Browse files
committed
Fix representation of SORT_TYPE_STILL_IN_PROGRESS.
It turns out that the code did indeed rely on a zeroedTuplesortInstrumentation.sortMethod field to indicate"this worker never did anything", although it seems theissue only comes up during certain race-condition-y cases.Hence, rearrange the TuplesortMethod enum to restoreSORT_TYPE_STILL_IN_PROGRESS to having the value zero,and add some comments reinforcing that that isn't optional.Also future-proof a loop over the possible values of the enum.sizeof(bits32) happened to be the correct limit value,but only by purest coincidence.Per buildfarm and local investigation.Discussion:https://postgr.es/m/12222.1586223974@sss.pgh.pa.us
1 parent4c04be9 commitc7654f6

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

‎src/backend/commands/explain.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,14 +2762,14 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo,
27622762
List*methodNames=NIL;
27632763

27642764
/* Generate a list of sort methods used across all groups. */
2765-
for (intbit=0;bit<sizeof(bits32);++bit)
2765+
for (intbit=0;bit<NUM_TUPLESORTMETHODS;bit++)
27662766
{
2767-
if (groupInfo->sortMethods& (1 <<bit))
2767+
TuplesortMethodsortMethod= (1 <<bit);
2768+
2769+
if (groupInfo->sortMethods&sortMethod)
27682770
{
2769-
TuplesortMethodsortMethod= (1 <<bit);
2770-
constchar*methodName;
2771+
constchar*methodName=tuplesort_method_name(sortMethod);
27712772

2772-
methodName=tuplesort_method_name(sortMethod);
27732773
methodNames=lappend(methodNames,unconstify(char*,methodName));
27742774
}
27752775
}

‎src/include/utils/tuplesort.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,24 @@ typedef struct SortCoordinateData *SortCoordinate;
6262
* TuplesortInstrumentation can't contain any pointers because we
6363
* sometimes put it in shared memory.
6464
*
65-
* TuplesortMethod is used in a bitmask in Increment Sort's shared memory
66-
* instrumentation so needs to have each value be a separate bit.
65+
* The parallel-sort infrastructure relies on having a zero TuplesortMethod
66+
* indicate that a worker never did anything, so we assign zero to
67+
* SORT_TYPE_STILL_IN_PROGRESS. The other values of this enum can be
68+
* OR'ed together to represent a situation where different workers used
69+
* different methods, so we need a separate bit for each one. Keep the
70+
* NUM_TUPLESORTMETHODS constant in sync with the number of bits!
6771
*/
6872
typedefenum
6973
{
70-
SORT_TYPE_STILL_IN_PROGRESS=1 <<0,
71-
SORT_TYPE_TOP_N_HEAPSORT=1 <<1,
72-
SORT_TYPE_QUICKSORT=1 <<2,
73-
SORT_TYPE_EXTERNAL_SORT=1 <<3,
74-
SORT_TYPE_EXTERNAL_MERGE=1 <<4
74+
SORT_TYPE_STILL_IN_PROGRESS=0,
75+
SORT_TYPE_TOP_N_HEAPSORT=1 <<0,
76+
SORT_TYPE_QUICKSORT=1 <<1,
77+
SORT_TYPE_EXTERNAL_SORT=1 <<2,
78+
SORT_TYPE_EXTERNAL_MERGE=1 <<3
7579
}TuplesortMethod;
7680

81+
#defineNUM_TUPLESORTMETHODS 4
82+
7783
typedefenum
7884
{
7985
SORT_SPACE_TYPE_DISK,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp