-
Notifications
You must be signed in to change notification settings - Fork 202
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?
Changes from 2 commits
12537a1
a292563
e9d086f
7a14d1b
7f3588a
0f86adc
5484528
d827e83
6233eb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -351,19 +351,27 @@ func (p *PXC) UninstallBinlogUDFComponent(ctx context.Context) error { | |
| } | ||
|
|
||
| func (p *PXC) CreateCollectorFunctions(ctx context.Context) error { | ||
| _, err := p.db.ExecContext(ctx, "CREATE FUNCTION IF NOT EXISTS get_last_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") | ||
| m := map[string]string{ | ||
| "get_last_record_timestamp_by_binlog": "INTEGER", | ||
| "get_gtid_set_by_binlog": "STRING", | ||
| "get_first_record_timestamp_by_binlog": "INTEGER", | ||
| } | ||
|
|
||
| _, err = p.db.ExecContext(ctx, "CREATE FUNCTION IF NOT EXISTS get_gtid_set_by_binlog RETURNS STRING SONAME 'binlog_utils_udf.so'") | ||
| if err != nil { | ||
| return errors.Wrap(err, "create function get_gtid_set_by_binlog") | ||
| } | ||
| for functionName, returnType := range m { | ||
| var x int | ||
| 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 | ||
| } | ||
|
Comment on lines
+363
to
+370
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that we are using the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, that's the whole point. |
||
|
|
||
| _, 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) | ||
|
||
| if _, err := p.db.ExecContext(ctx, createQ); err != nil { | ||
| return errors.Wrapf(err, "create function %s", functionName) | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
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.
e9d086f