-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve three scenarios that may cause workload to fail #422
Conversation
Hi @qinjingyuan ~ Thanks for your contribution in this PR. ❤️ Please make sure that your PR conforms the standard, and has passed all the checks. We will review your PR as soon as possible. |
Hey @qinjingyuan : Congratulations~ 🎉 Your commit has passed all the checks. Please wait for further manual review. |
Hey @qinjingyuan : Congratulations~ 🎉 Your commit has passed all the checks. Please wait for further manual review. |
src/backend/utils/misc/guc.c
Outdated
true, | ||
NULL,NULL,NULL | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增参数一般放在末尾,同时sql 长度已经有参数 polar_auditlog_max_query_length 控制,所以这个参数可以去除
src/backend/utils/error/elog.c
Outdated
@@ -4333,6 +4352,28 @@ polar_write_audit_log(ErrorData *edata, const char *fmt, ...) | |||
log_channel_write_buffer_pos); | |||
log_channel_write_buffer_pos = 0; | |||
polar_last_audit_log_flush_time = GetCurrentTimestamp(); | |||
// solving incomplete audit sql log problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
长度限制,直接去除
src/include/commands/prepare.h
Outdated
@@ -56,5 +57,5 @@ extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt); | |||
extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt); | |||
|
|||
extern void DropAllPreparedStatements(void); | |||
|
|||
extern char current_prepared_params_string[MAX_PREPARED_PARAMS_LEN]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里采用固定长度的数组存储参数信息,存在不能动态扩容的限制。建议采用 MemoryContext 机制进行实现动态扩容,内存可以存放在 ErrorContext 中,正常情况下 log 完手动释放,报错时由系统自动释放。
对于 simple 协议的prepared 语句,sql 的执行会强依赖 定义的SQL。如果pgreplay 中没有这个定义语句,则相关的 SQL 都不能回放。为了解决这个限制,需要在输出参数的同时,也要附带语句的定义 SQL。
src/backend/utils/error/elog.c
Outdated
@@ -4246,7 +4262,8 @@ polar_construct_logdata_postprocess(StringInfoData *logbuf, ErrorData *edata) | |||
else | |||
{ | |||
// NOTE(wormhole.gl): make sure logbuf length is not larger than PIPE_MAX_PAYLOAD | |||
polar_shrink_audit_log(logbuf, 0); | |||
if (polar_auditlog_max_query_length_limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
回退,不需要更改
src/backend/utils/error/elog.c
Outdated
@@ -2603,6 +2606,19 @@ log_line_prefix(StringInfo buf, ErrorData *edata) | |||
appendStringInfoString(buf, formatted_log_time); | |||
break; | |||
/* POLAR: new format for polar */ | |||
case 'L': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里利用 log_line_prefix 增加两个参数用来支持log search path 和 参数信息理论上是可以的。
但是考虑到新老版本兼容,以及周边生态的适配,如日志解析工具等,建议采用 直接将 上面两类信息和SQL文本一起输出。
在解析工具视角看,它就是一个SQL 文本,如果要适配,只需适配SQL 解析借口即可
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
利用两个 GUC 参数分别控制
src/backend/utils/error/elog.c
Outdated
@@ -116,8 +118,9 @@ char *Log_destination_string = NULL; | |||
bool syslog_sequence_numbers = true; | |||
bool syslog_split_messages = true; | |||
/* POLAR */ | |||
#define LOG_CHANNEL_WRITE_BUFFER_SIZE 128 * 1024 /* 128k */ | |||
#define LOG_CHANNEL_WRITE_BUFFER_SIZE 64 * 1024 /* 64k */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无效更改,回退
src/backend/commands/prepare.c
Outdated
@@ -226,6 +228,29 @@ ExecuteQuery(ExecuteStmt *stmt, IntoClause *intoClause, | |||
/* Look it up in the hash table */ | |||
entry = FetchPreparedStatement(stmt->name, true); | |||
|
|||
// get prepare params for solving parameterization problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要改变实现方式,见 prepare.h 中的评论。
同时 对于 explain (analyze) execute s(1);
场景,也需要支持。
这里只是针对 走simple 协议的 prepared 场景,对于走 extended 协议的场景,也需要输出参数信息,见 exec_execute_message
函数
Hey @qinjingyuan : Something wrong occuried during the checks of your commit 😟, please check the detail:
|
Hey @qinjingyuan : Something wrong occuried during the checks of your commit 😟, please check the detail:
|
reopen |
reopen pr |
Hey @qinjingyuan : Something wrong occuried during the checks of your commit 😟, please check the detail:
|
Hey @qinjingyuan : Congratulations~ 🎉 Your commit has passed all the checks. Please wait for further manual review. |
analyze poalrdb log file and monitor db system info. 1. support log search_path info to log file. 2. support log paremeters type for parameterization SQL. Only parameters type is logged for extended protocol. Parameters type and definnitation of SQL are logged for PREPARED simple protocol. 3. Add pgreplay tool. currently, this version pgreplay can support polardb audit log and workload replay monitor function 4. Support extension protocol of pg execution and normal execution when prepare is not present on pgreplay.
Hey @qinjingyuan : Congratulations~ 🎉 Your commit has passed all the checks. Please wait for further manual review. |
/rebase-and-merge |
@mrdrivingduck PR has been merged. 🍗 Thanks again for the contributors involved in this thread: ❤️ |
resolve problems in describing #403.
using mothed:https://github.com/qinjingyuan/pgreplay-for-polardb