Several fixed in Prepared statements

* is STMT_PREPARE failed when there is a previous status (maybe STMT_EXECUTE) disconnect the client immediately. Maybe this is related to #1366 , but I can't reproduce it yet
* purge prepared statements is also their server reference counter is 0
* initialize connections queue for purging connections
pull/1434/head
René Cannaò 8 years ago
parent c3040acc74
commit 2bb322db6f

@ -831,6 +831,7 @@ MySQL_HostGroups_Manager::MySQL_HostGroups_Manager() {
mydb->execute(MYHGM_MYSQL_SERVERS_INCOMING);
mydb->execute(MYHGM_MYSQL_REPLICATION_HOSTGROUPS);
mydb->execute(MYHGM_MYSQL_GROUP_REPLICATION_HOSTGROUPS);
queue = wqueue<MySQL_Connection *>();
MyHostGroups=new PtrArray();
incoming_replication_hostgroups=NULL;
incoming_group_replication_hostgroups=NULL;

@ -532,16 +532,18 @@ void MySQL_STMT_Manager_v14::ref_count_client(uint64_t _stmt_id ,int _v, bool lo
continue; // nothing left to clean up
}
MySQL_STMT_Global_info *a = it->second;
if (__sync_add_and_fetch(&a->ref_count_client, 0) == 0) {
if ((__sync_add_and_fetch(&a->ref_count_client, 0) == 0) &&
(a->ref_count_server == 0) ) // this to avoid that IDs are incorrectly reused
{
uint64_t hash = a->hash;
auto s2 = map_stmt_hash_to_info.find(hash);
if (s2 != map_stmt_hash_to_info.end()) {
map_stmt_hash_to_info.erase(s2);
}
__sync_sub_and_fetch(&num_stmt_with_ref_client_count_zero,1);
if (a->ref_count_server == 0) {
//if (a->ref_count_server == 0) {
//__sync_sub_and_fetch(&num_stmt_with_ref_server_count_zero,1);
}
//}
// m.erase(it);
// delete a;
i++;

@ -2906,6 +2906,13 @@ handler_again:
sprintf(sqlstate,"%s",mysql_sqlstate(myconn->mysql));
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,client_myds->pkt_sid+1,mysql_errno(myconn->mysql),sqlstate,(char *)mysql_stmt_error(myconn->query.stmt));
client_myds->pkt_sid++;
if (previous_status.size()) {
// an STMT_PREPARE failed
// we have a previous status, probably STMT_EXECUTE,
// but returning to that status is not safe after STMT_PREPARE failed
// for this reason we exit immediately
wrong_pass=true;
}
}
break;
case PROCESSING_STMT_EXECUTE:

Loading…
Cancel
Save