Description:
Fabric connectivity stops working with the following error after a shard is created in the cluster. Starts working again if the shard definition is removed.
MySql.Fabric.MySqlFabricException was unhandled
HResult=-2146233088
Message=Unable to connect to Fabric server.
Source=MySql.Fabric.Plugin
StackTrace:
at MySql.Fabric.FabricServerGroup.GetServerList()
at MySql.Fabric.FabricServerGroup.GetServer(Boolean isMaster, MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.Replication.ReplicationManager.GetNewConnection(String groupName, Boolean master, MySqlConnection connection)
at MySql.Data.MySqlClient.MySqlConnection.Open()
at FabricTest.Program.RunFabricTest() in c:\users\dhanabdi\documents\visual studio 2015\Projects\Shard_test1\Shard_test1\Program.cs:line 97
at FabricTest.Program.Main(String[] args) in c:\users\dhanabdi\documents\visual studio 2015\Projects\Shard_test1\Shard_test1\Program.cs:line 28
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
HResult=-2147024809
Message=An item with the same key has already been added.
Source=mscorlib
StackTrace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at MySql.Fabric.FabricServerGroup.GetShards()
at MySql.Fabric.FabricServerGroup.GetServerList()
InnerException:
How to repeat:
I created a cluster of 3 groups of servers ( 2 servers each) for a total of 6 servers plus a dedicated server for Fabric. Got 1 global group and 2 high availability groups configured with the GTID replication.
Next try a console application as explained in the example
https://dev.mysql.com/doc/connector-net/en/connector-net-programming-fabric.html
I am using mysql connector net 6.9.8 version.
MySQL fabric 1.5
Run the example as in the link from visual studio(15) and ensure it works fine.
Now add a shard definition from the command line using the following command.
>mysqlfabric sharding create_definition HASH ha_global
where ha_global is the name of my global group.
Now try the console application again and the error occurs!
Suggested fix:
When I look at netstat -a -b when the connection errors I see a valid connection at port 32275 like it should be. SO, looks like it is an error that is happening after the connection is established due to some steps happening after that and before a success message is sent out.