Skip to content

Commit

Permalink
Fix index in array to accommodate parallel workers
Browse files Browse the repository at this point in the history
Use poscan->worker_active array for Asserts only.
  • Loading branch information
pashkinelfe authored and akorotkov committed Jun 11, 2024
1 parent 6de6b11 commit da149b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/tableam/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ typedef struct ParallelOScanDescData
dsm_handle dsmHandle;
/* debug only */
int cur_int_pageno;
bool worker_active[10];
#ifdef USE_ASSERT_CHECKING
bool worker_active[1024];
#endif
} ParallelOScanDescData;

typedef ParallelOScanDescData *ParallelOScanDesc;
Expand Down
7 changes: 6 additions & 1 deletion src/btree/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,13 +1039,18 @@ init_btree_seq_scan(BTreeSeqScan *scan)
* after all workers completed their scans).
*/
SpinLockAcquire(&poscan->workerStart);
#ifdef USE_ASSERT_CHECKING
for (scan->workerNumber = 0; poscan->worker_active[scan->workerNumber] == true; scan->workerNumber++)
{
}

poscan->worker_active[scan->workerNumber] = true;
poscan->nworkers = scan->workerNumber + 1;
/* leader */
#else
scan->workerNumber = poscan->nworkers;
poscan->nworkers++;
#endif
/* Scan leader */
if (scan->workerNumber == 0)
{
Assert(!(poscan->flags & O_PARALLEL_LEADER_STARTED));
Expand Down

0 comments on commit da149b9

Please sign in to comment.