Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
HAWQ-1823. avoid of reallocating resource in udf
Browse files Browse the repository at this point in the history
  • Loading branch information
ztao1987 committed Dec 27, 2021
1 parent d01b19b commit bd88dbd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/backend/commands/indexcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ bool CDBCreateIndex(IndexStmt *stmt, Oid relationOid, Oid indexOid)

elog(DEBUG1, "CDBCreateIndex virtual segment number is: %d\n", target_segment_num);

QueryResource *resource = AllocateResource(QRL_ONCE, 1, 1, target_segment_num, target_segment_num, NULL, 0);
QueryResource *resource = NULL;
QueryResource *savedResource = NULL;
savedResource = GetActiveQueryResource();
if (!savedResource) {
resource = AllocateResource(QRL_ONCE, 1, 1, target_segment_num, target_segment_num, NULL, 0);
} else {
resource = AllocateResource(QRL_INHERIT, 0, 0, 0, 0, NULL, 0);
}
SetActiveQueryResource(resource);

/* 4.bind SegNO to Vseg */
int total_segfiles = 0;
Expand Down
14 changes: 11 additions & 3 deletions src/backend/commands/tablecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -7219,8 +7219,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
}
}

resource = AllocateResource(QRL_ONCE, 1, 1, target_segment_num, target_segment_num,NULL,0);
savedResource = GetActiveQueryResource();
savedResource = GetActiveQueryResource();
if (!savedResource) {
resource = AllocateResource(QRL_ONCE, 1, 1, target_segment_num, target_segment_num,NULL,0);
} else {
resource = AllocateResource(QRL_INHERIT, 0, 0, 0, 0, NULL, 0);
}
SetActiveQueryResource(resource);

segment_segnos = SetSegnoForWrite(NIL, 0, target_segment_num, true, true, false);
Expand Down Expand Up @@ -17578,8 +17582,12 @@ ATPExecPartSplit(Relation rel,

}

resource = AllocateResource(QRL_ONCE, 1, 1, target_segment_num, target_segment_num, NULL, 0);
savedResource = GetActiveQueryResource();
if (!savedResource) {
resource = AllocateResource(QRL_ONCE, 1, 1, target_segment_num, target_segment_num, NULL, 0);
} else {
resource = AllocateResource(QRL_INHERIT, 0, 0, 0, 0, NULL, 0);
}
SetActiveQueryResource(resource);
segment_segnos = SetSegnoForWrite(NIL, 0, target_segment_num, true, true, false);
scantable_splits = NIL;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/resourcemanager/resqueuemanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -4385,8 +4385,8 @@ void buildAcquireResourceResponseMessage(ConnectionTrack conn)
conn->MessageID = RESPONSE_QD_ACQUIRE_RESOURCE;
conn->ResAllocTime = gettime_microsec();

elog(LOG, "latency of getting resource allocated is "UINT64_FORMAT "us",
conn->ResAllocTime - conn->ResRequestTime);
elog(LOG, "ConnID %d latency of getting resource allocated is "UINT64_FORMAT "us",
conn->ConnID, conn->ResAllocTime - conn->ResRequestTime);

MEMORY_CONTEXT_SWITCH_TO(PCONTEXT)
PCONTRACK->ConnToSend = lappend(PCONTRACK->ConnToSend, conn);
Expand Down

0 comments on commit bd88dbd

Please sign in to comment.