-
Notifications
You must be signed in to change notification settings - Fork 204
K8SPXC-1748: add checks before creating functions in collector #2264
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
base: main
Are you sure you want to change the base?
Conversation
egegunes
left a comment
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.
@pooknull we need to create these functions in entrypoint too so there won't be any DDL when you enable PiTR on a running cluster.
handling these in the collector is to cover an edge case where users have an old cluster with pitr disabled and they want to enable it after upgrading to v1.19.0. if we just create these functions in entrypoint, that'd create problems.
| err := p.db.QueryRowContext(ctx, `SELECT 1 FROM mysql.func WHERE name = ? LIMIT 1`, functionName).Scan(&x) | ||
| if err != nil && !errors.Is(err, sql.ErrNoRows) { | ||
| return errors.Wrapf(err, "check if function %s exists", functionName) | ||
| } | ||
| if err == nil { | ||
| log.Printf("function %s already exists", functionName) | ||
| continue | ||
| } |
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.
Given that we are using the IF NOT EXISTS on the subsequent query, is this check regarding the existence of the function necessary?
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.
yes, that's the whole point. CREATE IF NOT EXISTS still counts as DDL
cmd/pitr/pxc/pxc.go
Outdated
| _, err = p.db.ExecContext(ctx, "CREATE FUNCTION IF NOT EXISTS get_first_record_timestamp_by_binlog RETURNS INTEGER SONAME 'binlog_utils_udf.so'") | ||
| if err != nil { | ||
| return errors.Wrap(err, "create function get_first_record_timestamp_by_binlog") | ||
| createQ := fmt.Sprintf("CREATE FUNCTION IF NOT EXISTS %s RETURNS %s SONAME 'binlog_utils_udf.so'", functionName, returnType) |
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.
we need to wrap this with SET SESSION wsrep_on = OFF; and SET SESSION wsrep_on = ON;
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.
build/pxc-entrypoint.sh
Outdated
| echo "CREATE FUNCTION IF NOT EXISTS get_last_record_timestamp_by_binlog RETURNS INTEGER SONAME 'binlog_utils_udf.so'" | "${mysql[@]}" | ||
|
|
||
| echo "CREATE FUNCTION IF NOT EXISTS get_gtid_set_by_binlog RETURNS STRING SONAME 'binlog_utils_udf.so'" | "${mysql[@]}" | ||
|
|
||
| echo "CREATE FUNCTION IF NOT EXISTS get_first_record_timestamp_by_binlog RETURNS INTEGER SONAME 'binlog_utils_udf.so'" | "${mysql[@]}" |
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.
i see a lot of test failures with the error full cluster crash detected. probably these statements are the reason. also do we have these in mysql 5.7?
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.
|
@pooknull please add description |
build/pxc-entrypoint.sh
Outdated
| fi | ||
| set -x | ||
|
|
||
| if [ "$MYSQL_VERSION" == '8.0' ]; then |
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.
let's check for 8.4 as well
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.
commit: 5484528 |
hors
left a comment
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.
@pooknull @egegunes We have a problem with smart-update tests - full cluster crash detected
-----------------------------------------------------------------------------------
wait for running cluster
-----------------------------------------------------------------------------------
++ seq 0 2
+ for i in '$(seq 0 $last_pod)'
+ wait_pod smart-update-pxc-0 480
+ local pod=smart-update-pxc-0
+ local max_retry=480
+ local ns=
++ echo smart-update-pxc-0
++ /usr/bin/sed -E 's/.*-(pxc|proxysql)-[0-9]/\1/'
++ grep -E '^(pxc|proxysql)$'
+ local container=pxc
+ set +o xtrace
pod/smart-update-pxc-0 condition met
waiting for pod/smart-update-pxc-0 to become Ready.full cluster crash detected
https://perconadev.atlassian.net/browse/K8SPXC-1748
DESCRIPTION
Problem:
When PITR is enabled, the collector runs the following DDL statements each time it starts:
CREATE FUNCTION IF NOT EXISTS get_last_record_timestamp_by_binlog RETURNS INTEGER SONAME 'binlog_utils_udf.so'CREATE FUNCTION IF NOT EXISTS get_gtid_set_by_binlog RETURNS STRING SONAME 'binlog_utils_udf.so'CREATE FUNCTION IF NOT EXISTS get_first_record_timestamp_by_binlog RETURNS INTEGER SONAME 'binlog_utils_udf.so'Galera treats it as a replicated DDL operation and engages TOI
Solution:
These statements should be executed in the
pxc-entrypoint. The collector should verify that these functions exist and create them if they do not (as a safeguard).CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability