Skip to content

Commit afb74f1

Browse files
author
Arun Kuruvila
committed
Bug#32989716: MISSING CORRECT CLOSE SESSION HANDLING DURING
KEYRING MIGRATION Description: Keyring migration server uses a mysql connection to perform online migration. This mysql session is not closed gracefully after the migration. This leads to a 'Note' being printed on the online server error log:- "[Note] Aborted connection x to db: 'xyz' user: 'abc' host: 'localhost' (Got an error reading communication packets)" Analysis: After the online keyring migration, migration server process is aborted before gracefully closing the mysql session. This happens because the migration server process exits before calling the destructor of 'Migrate_keyring', where the closing of the mysql session is handled. Fix: This issue is fixed in 8.0 as part of a code refactoring done in this area by WL#13446. Back-porting the relevant code changes to 5.7 to fix this bug and to make the code consistent across versions. RB#27186
1 parent ba28972 commit afb74f1

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

sql/mysqld.cc

+32-26
Original file line numberDiff line numberDiff line change
@@ -4704,37 +4704,43 @@ int mysqld_main(int argc, char **argv)
47044704
opt_keyring_migration_destination ||
47054705
migrate_connect_options)
47064706
{
4707-
Migrate_keyring mk;
4708-
if (mk.init(remaining_argc, remaining_argv,
4709-
opt_keyring_migration_source,
4710-
opt_keyring_migration_destination,
4711-
opt_keyring_migration_user,
4712-
opt_keyring_migration_host,
4713-
opt_keyring_migration_password,
4714-
opt_keyring_migration_socket,
4715-
opt_keyring_migration_port))
4707+
int exit_state = MYSQLD_ABORT_EXIT;
4708+
while (true)
47164709
{
4717-
sql_print_error(ER_DEFAULT(ER_KEYRING_MIGRATION_STATUS),
4718-
"failed");
4719-
log_error_dest= "stderr";
4720-
flush_error_log_messages();
4721-
unireg_abort(MYSQLD_ABORT_EXIT);
4722-
}
4710+
Migrate_keyring mk;
4711+
if (mk.init(remaining_argc, remaining_argv,
4712+
opt_keyring_migration_source,
4713+
opt_keyring_migration_destination,
4714+
opt_keyring_migration_user,
4715+
opt_keyring_migration_host,
4716+
opt_keyring_migration_password,
4717+
opt_keyring_migration_socket,
4718+
opt_keyring_migration_port))
4719+
{
4720+
sql_print_error(ER_DEFAULT(ER_KEYRING_MIGRATION_STATUS),
4721+
"failed");
4722+
log_error_dest= "stderr";
4723+
flush_error_log_messages();
4724+
break;
4725+
}
47234726

4724-
if (mk.execute())
4725-
{
4726-
sql_print_error(ER_DEFAULT(ER_KEYRING_MIGRATION_STATUS),
4727-
"failed");
4727+
if (mk.execute())
4728+
{
4729+
sql_print_error(ER_DEFAULT(ER_KEYRING_MIGRATION_STATUS),
4730+
"failed");
4731+
log_error_dest= "stderr";
4732+
flush_error_log_messages();
4733+
break;
4734+
}
4735+
4736+
sql_print_information(ER_DEFAULT(ER_KEYRING_MIGRATION_STATUS),
4737+
"successful");
47284738
log_error_dest= "stderr";
47294739
flush_error_log_messages();
4730-
unireg_abort(MYSQLD_ABORT_EXIT);
4740+
exit_state = MYSQLD_SUCCESS_EXIT;
4741+
break;
47314742
}
4732-
4733-
sql_print_information(ER_DEFAULT(ER_KEYRING_MIGRATION_STATUS),
4734-
"successful");
4735-
log_error_dest= "stderr";
4736-
flush_error_log_messages();
4737-
unireg_abort(MYSQLD_SUCCESS_EXIT);
4743+
unireg_abort(exit_state);
47384744
}
47394745

47404746
/*

0 commit comments

Comments
 (0)