Skip to content

Commit b7cca05

Browse files
Re-applied temporarily partially reverted fix for PS-9453
Re-applied the fix for PS-9453 "percona_telemetry causes a long wait on COND_thd_list due to the absence of the root user" (commit e53363d) partially reverted previously. After changes in 'cssm_begin_connect()' instead of cherry-picking from 8.0 branch the modified patch from 8.4 was taken. This is a finalization step of for cherry-picking Bug #34741098 "component::deinit() will block if calling any registry update APIs" (commit mysql/mysql-server@d39330f).
1 parent d4a8212 commit b7cca05

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sql/server_component/mysql_command_backend.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,20 @@ mysql_state_machine_status cssm_begin_connect(mysql_async_connect *ctx) {
211211
mysql_service_registry_t *registry_service =
212212
no_lock_registry ? srv_registry_no_lock : srv_registry;
213213

214+
/* We need to handle the failure in this function.
215+
Setting mcs_extn->session_svc right after session open is not enough
216+
to handle user lookup errors (and following errors as well)
217+
because in case of this function returns error, mysql->extension is
218+
cleaned up immediately by the caller. The caller does not take care of
219+
session_svc, because it is not aware of this structure.
220+
*/
221+
std::shared_ptr<MYSQL_SESSION> mysql_session_close_guard(
222+
&mysql_session, [mcs_extn](MYSQL_SESSION *mysql_session_ptr) {
223+
if (*mysql_session_ptr == nullptr) return;
224+
mcs_extn->session_svc = nullptr;
225+
srv_session_close(*mysql_session_ptr);
226+
});
227+
214228
if (mcs_extn->mcs_thd == nullptr || mcs_extn->session_svc == nullptr) {
215229
/*
216230
Avoid possibility of nested txn in the current thd.
@@ -253,6 +267,7 @@ mysql_state_machine_status cssm_begin_connect(mysql_async_connect *ctx) {
253267
if (status == STATE_MACHINE_FAILED) return status;
254268
mysql->client_flag = 0; /* For handshake */
255269
mysql->server_status = SERVER_STATUS_AUTOCOMMIT;
270+
mysql_session = nullptr; // disable delete quard
256271
return STATE_MACHINE_DONE;
257272
}
258273

0 commit comments

Comments
 (0)