Skip to content

Commit

Permalink
[columnar] Adds memory fences around stripe combinations and reorgani…
Browse files Browse the repository at this point in the history
…zation (#102)
  • Loading branch information
JerrySievert authored Jun 30, 2023
1 parent a62d86b commit 4fe7029
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions columnar/src/backend/columnar/columnar_tableam.c
Original file line number Diff line number Diff line change
Expand Up @@ -3123,6 +3123,10 @@ vacuum_columnar_table(PG_FUNCTION_ARGS)
{
StripeVacuumCandidate *vacuumCandidate = lfirst(lc);

MemoryContext combineContext = AllocSetContextCreate(CurrentMemoryContext,
"Stripe Combine Context", ALLOCSET_DEFAULT_SIZES);
MemoryContext previousContext = MemoryContextSwitchTo(combineContext);

ColumnarReadState *readState = init_columnar_read_state(rel, tupleDesc,
attr_needed, scanQual,
scanContext, snapshot,
Expand All @@ -3138,6 +3142,7 @@ vacuum_columnar_table(PG_FUNCTION_ARGS)

int32 rowCount = 0;


while (rowCount < vacuumCandidate->activeRows && ColumnarReadNextRow(readState, values, nulls, NULL))
{
ColumnarWriteRow(writeState, values, nulls);
Expand Down Expand Up @@ -3188,6 +3193,9 @@ vacuum_columnar_table(PG_FUNCTION_ARGS)
{
break;
}

MemoryContextSwitchTo(previousContext);
MemoryContextDelete(combineContext);
}
/*
* We have finished the first route of writes, let's drop our lock until we are
Expand All @@ -3202,6 +3210,10 @@ vacuum_columnar_table(PG_FUNCTION_ARGS)
bool done = false;
while (!done)
{
MemoryContext rewriteContext = AllocSetContextCreate(CurrentMemoryContext,
"Stripe Rewrite Context", ALLOCSET_DEFAULT_SIZES);
MemoryContext previousContext = MemoryContextSwitchTo(rewriteContext);

/* Check if a signal has been sent, if so close out and deal with it. */
if (need_to_bail)
{
Expand Down Expand Up @@ -3303,6 +3315,9 @@ vacuum_columnar_table(PG_FUNCTION_ARGS)

holes = HolesForRelation(rel);
}

MemoryContextSwitchTo(previousContext);
MemoryContextDelete(rewriteContext);
}


Expand Down

0 comments on commit 4fe7029

Please sign in to comment.