Description:
in MySqlCommand.ExecuteReader(CommandBehavior behavior), it calls ReplicationManager.GetNewConnection() to load balancing a new connection.driver object, However, the new created connection driver doesn't call driver.configure(), and therefore its serverProperties, charSets and MaxPacketSize doesn' get initialized.
this issue causes MySqlConnection use default 1024 packet size, and doesn't have any server properties nor charsets. And cause Dapper works incorrectly.
How to repeat:
1. prepare a mysql replication group
2. create a .net console project, set replication configuration in app.config
<Group name="RO_rm-bp18wl1bs7798649v">
<Servers>
<Server name="server1" IsMaster="true" connectionstring="database=ka_leaderm;server=rr-bp1p34uoxxxxx;port=3306;uid=xxx;password=xxx;Max Pool Size=100;" />
<Server name="server2" IsMaster="true" connectionstring="database=ka_leaderm;server=rr-bp1p35uoxxxxx;port=3306;uid=xxx;password=xxx;Max Pool Size=100;" />
</Servers>
</Group>
3. in code, create an connection and execute reader
var connstr = "server=RO_rm-bp18wl1bs7798649v;";
var conn3 = new MySql.Data.MySqlClient.MySqlConnection(connstr);
conn3.Open();
var reader = conn3.ExecuteReader("select * from patient limit 1");
Suggested fix:
a simple fix should be: always configure the driver after driver get created
Description: in MySqlCommand.ExecuteReader(CommandBehavior behavior), it calls ReplicationManager.GetNewConnection() to load balancing a new connection.driver object, However, the new created connection driver doesn't call driver.configure(), and therefore its serverProperties, charSets and MaxPacketSize doesn' get initialized. this issue causes MySqlConnection use default 1024 packet size, and doesn't have any server properties nor charsets. And cause Dapper works incorrectly. How to repeat: 1. prepare a mysql replication group 2. create a .net console project, set replication configuration in app.config <Group name="RO_rm-bp18wl1bs7798649v"> <Servers> <Server name="server1" IsMaster="true" connectionstring="database=ka_leaderm;server=rr-bp1p34uoxxxxx;port=3306;uid=xxx;password=xxx;Max Pool Size=100;" /> <Server name="server2" IsMaster="true" connectionstring="database=ka_leaderm;server=rr-bp1p35uoxxxxx;port=3306;uid=xxx;password=xxx;Max Pool Size=100;" /> </Servers> </Group> 3. in code, create an connection and execute reader var connstr = "server=RO_rm-bp18wl1bs7798649v;"; var conn3 = new MySql.Data.MySqlClient.MySqlConnection(connstr); conn3.Open(); var reader = conn3.ExecuteReader("select * from patient limit 1"); Suggested fix: a simple fix should be: always configure the driver after driver get created