0

I have setup SQL Server 2016 linkedserver to connect to MySQL 8 instance and created stored procedure that insert data from SQL Server database to MySQL database using open query, it works fine when I called the procedure, it inserts the records to MySQL. However, when I create multiple procedures that insert the data to MySQL and call all the procedures at once it fails.

I'm using windows server 2016 VM and Google Cloud Managed MySQL Instance, and ODBC unicode driver 8.4

Example: When I call a procedure separately like below it works.

EXEC insert_data_db1 @p = 1;

I have another procedure with multiple sub procedures like this, when I called this procedure with multiple sub procs, it failed with the following error message.

EXEC insert_data_db1 @p = 1;
EXEC insert_data_db2 @p = 2;
EXEC insert_data_db3 @p = 3;

Each of the procedure have multiple insert statements like these;

INSERT INTO OPENQUERY([server],'SELECT  id, name, state_date, created_at, updated_at, created_byFROM `Db1`.table1')
SELECT  id, name, state_date, created_at, updated_at, created_by FROM source a

Errror;

OLE DB provider "MSDASQL" for linked server "LinkedServer" returned message "[MySQL][ODBC 8(w) Driver]Can't connect to MySQL server on 'ip:port' (10060)".

Need some help, what might be the issue?

6
  • No idea what's the issue, but insert into OPENQUERY is the worst way of doing it. You could use four-part server names to directly insert into a mysql table, something like: insert into [server].[db]..[table] (col1, ... colX) select ... from source, although, some providers don't implement this correctly Commented Aug 26, 2024 at 8:55
  • This case [server] should be IP address right? Commented Aug 26, 2024 at 9:05
  • it should be whatever the name of the server is in the sys.sysservers view Commented Aug 26, 2024 at 9:08
  • Thanx will try this Commented Aug 26, 2024 at 9:43
  • Hi when i remove the openquery inserts and replace with four-part server name to insert directly to mysql, and execute alter procedure it gives me a same erro message says "[MySQL][ODBC 8.4(w) Driver]Can't connect to MySQL server on ':' (10060)"., Im not be able to alter procdure with four-part server names, due to this. Please advice Commented Aug 26, 2024 at 17:29

1 Answer 1

0

So you are saying it works when you only run the stored proc once, but fails when you run multiple instances of it parallelly at once.

Are you doing this in Management Studio?

Might be a long shot, but Linked Server connections are just single threaded, so if one thread is already taken, maybe the rest is refused?

You could try breaking it up to steps so that SSMS executes them individually in sequence:

EXEC insert_data_db1 @p = 1;
GO
EXEC insert_data_db2 @p = 2;
GO
EXEC insert_data_db3 @p = 3;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.