This is an automated email from the ASF dual-hosted git repository. ztao1987 pushed a commit to branch ztao in repository https://gitbox.apache.org/repos/asf/hawq.git
commit 6f927fb38a1c9784368014aece9bbc7aa8ac0944 Author: xsheng <stanly.sxi...@gmail.com> AuthorDate: Wed Aug 19 18:00:07 2020 +0800 SUPPORT-416. fix rewrite ddl request resoure in UDF --- src/backend/commands/indexcmds.c | 10 +++++++++- src/backend/commands/tablecmds.c | 14 +++++++++++--- src/backend/resourcemanager/resqueuemanager.c | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 1c8c3d1..fdd065e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -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; diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index a21d803..60dc98b 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -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); @@ -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; diff --git a/src/backend/resourcemanager/resqueuemanager.c b/src/backend/resourcemanager/resqueuemanager.c index 16d4087..1a8807a 100644 --- a/src/backend/resourcemanager/resqueuemanager.c +++ b/src/backend/resourcemanager/resqueuemanager.c @@ -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);