Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build/pxc-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,12 @@ if [ -z "$CLUSTER_JOIN" ] && [ "$1" = 'mysqld' ] && [ -z "$wantHelp" ]; then
fi
set -x

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[@]}"
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


echo
ls /docker-entrypoint-initdb.d/ >/dev/null
for f in /docker-entrypoint-initdb.d/*; do
Expand Down
28 changes: 18 additions & 10 deletions cmd/pitr/pxc/pxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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?

Copy link
Contributor

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


_, 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)
Copy link
Contributor

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;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if _, err := p.db.ExecContext(ctx, createQ); err != nil {
return errors.Wrapf(err, "create function %s", functionName)
}
}

return nil
Expand Down
12 changes: 12 additions & 0 deletions e2e-tests/pitr/run
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ main() {
cluster="pitr"
spinup_pxc "$cluster" "$test_dir/conf/$cluster.yml"

pitr_pod=$(
kubectl_bin get pods \
--selector="app.kubernetes.io/component=pitr" \
-o 'jsonpath={.items[].metadata.name}'
)
wait_pod "$pitr_pod"
function_exists_count=$(kubectl_bin logs -l "app.kubernetes.io/component=pitr" --tail=-1 2>/dev/null | grep -c 'already exists')
if [ "$function_exists_count" -eq 0 ]; then
echo "There are no 'function ... already exists' logs"
exit 1
fi

run_backup "$cluster" "on-pitr-minio"

# Temporarily skipping this check
Expand Down
Loading