Skip to content

Commit

Permalink
Merge pull request #3976 from sysown/v2.x-3928
Browse files Browse the repository at this point in the history
Fix isolation level in AWS Aurora
  • Loading branch information
renecannao authored Sep 15, 2022
2 parents 83ffb72 + 8344be1 commit 3b13c7c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2478,8 +2478,24 @@ bool MySQL_Session::handler_again___status_SETTING_GENERIC_VARIABLE(int *_rc, co
else {
sprintf(query,q,"tx_isolation", var_value);
}
}
else {
} else if (strncasecmp("aurora_read_replica_read_committed", var_name, 34) == 0) {
// If aurora_read_replica_read_committed is set, isolation level is
// internally reset so that it will be set again.
// This solves the weird behavior in AWS Aurora related to isolation level
// as described in
// https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Reference.html#AuroraMySQL.Reference.IsolationLevels
// Basically, to change isolation level you must first set
// aurora_read_replica_read_committed , and then isolation level
MySQL_Connection *beconn = mybe->server_myds->myconn;
if (beconn->var_hash[SQL_ISOLATION_LEVEL] != 0) {
beconn->var_hash[SQL_ISOLATION_LEVEL] = 0;
if (beconn->variables[SQL_ISOLATION_LEVEL].value) {
free(beconn->variables[SQL_ISOLATION_LEVEL].value);
beconn->variables[SQL_ISOLATION_LEVEL].value = NULL;
}
}
sprintf(query,q,var_name, var_value);
} else {
sprintf(query,q,var_name, var_value);
}
query_length=strlen(query);
Expand Down

0 comments on commit 3b13c7c

Please sign in to comment.