issue修改:修改gsql命令行执行命令时,部分暂存区的语句被清空没有上传至statement_history中的问题

This commit is contained in:
Julong-Li
2024-01-26 16:33:19 +08:00
committed by zhang_xubo
parent 6db7135b32
commit 89e8a63d49
3 changed files with 13 additions and 4 deletions

View File

@ -887,7 +887,6 @@ static void FlushAllStatement()
static void StatementFlush()
{
const int flush_usleep_interval = 100000;
int count = 0;
bool is_readonly_log_needed = false;
@ -899,7 +898,7 @@ static void StatementFlush()
ereport(WARNING, (errmodule(MOD_INSTR),
errmsg("[Statement] cannot flush suspend list to statement_history in a read-only transaction")));
}
pg_usleep(flush_usleep_interval);
pg_usleep(FLUSH_USLEEP_INTERVAL);
continue;
}
if (is_readonly_log_needed) {
@ -919,7 +918,7 @@ static void StatementFlush()
/* report statement_history state to pgstat */
if (OidIsValid(u_sess->proc_cxt.MyDatabaseId))
pgstat_report_stat(true);
pg_usleep(flush_usleep_interval);
pg_usleep(FLUSH_USLEEP_INTERVAL);
}
}

View File

@ -51,6 +51,7 @@
#include "utils/plog.h"
#include "threadpool/threadpool.h"
#include "instruments/instr_user.h"
#include "instruments/instr_statement.h"
#include "utils/postinit.h"
#ifdef ENABLE_MOT
#include "storage/mot/mot_fdw.h"
@ -167,6 +168,15 @@ void proc_exit(int code)
}
}
/* Wait for all statements that have not been flushed to complete flushing.
* The flush usleep wait interval is 100,000 microseconds,
* therefore we set it here to 300,000 microseconds for a safe margin.
*/
if (u_sess->statement_cxt.suspend_count != 0) {
int flushWaitInterval = 3 * FLUSH_USLEEP_INTERVAL;
pg_usleep(flushWaitInterval);
}
if (t_thrd.utils_cxt.backend_reserved) {
ereport(DEBUG2, (errmodule(MOD_MEM),
errmsg("[BackendReservedExit] current thread role is: %d, used memory is: %d MB\n",

View File

@ -162,7 +162,7 @@ struct StatementDetail {
#define STATEMENT_DETAIL_TYPE_PRETTY "pretty"
#define Anum_statement_history_finish_time 12
#define FLUSH_USLEEP_INTERVAL 100000
/* entry for full/slow sql stat */
typedef struct StatementStatContext {
void *next; /* next item if in free or suspend list */