Running MSSQL Server 2008 Standard SP 2 64-bit on Win2K8. I have installed on this server the 64-bit MySQL ODBC driver version 5.1.8 from 10/28/2010. I have configured a DSN linking to a MySQL server 5.1 running on a Mac apple-darwin9.8.0 server (don't ask me, I inherited this). I have successfully created a linked server via MDSASQL to a specific MySQL database.
From the SQL Server box I can run simple queries of the nature
SELECT * FROM mysql_table WHERE id = 1;
However, it is painfully slow. A query as above takes 19 minutes and 52 seconds to execute; the same query takes 0.04 seconds when executed locally.
Further, I attempted to execute a simple update of the nature
UPDATE mysql_table SET field = 0 WHERE id = 1;
This ran for 2 hours before returning the following error:
OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL" returned message "Out of memory.".
Msg 7399, Level 16, State 1, Line 3
The OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL" reported an error. The provider ran out of memory.
Msg 7330, Level 16, State 2, Line 3
Cannot fetch a row from OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL".
This comes on the heels of several failed jobs involving updates to the same table, all of which fail approximately two hours after they commence.
I have checked the permissions on the mysql and the user specified in the DSN has the appropriate permissions (well, all permissions) in mysql.user.
I would be most appreciative if anyone could give me any avenues to investigate to get this working.
Avoid joins to linked server tables and have a look at dynamic openqueries
And refer to this question that posted ealier.
Linked Server Performance and options
Related
I have an application which connects and stores data on a MySQL database, I need to connect and retrieve this data in a view from another application which uses an SQL Server Database. My attempt to handle this was to create a linked server that connects to the MySQL Server in SQL Server.
That seems to have worked, all connections have passed and if I run the following queries
SELECT * FROM MYSQLLINK...table1` or `SELECT * FROM OPENQUERY(MYSQLLINK, 'SELECT * FROM table1')
I get results.
Problem
The problem is, I want to create a view which joins quite a few reference tables ( I actually have 20 joins but it's joining the same table because it's a big reference table.)
but on execution on the SELECT or CREATE VIEW I get the following error.
OLE DB provider "MSDASQL" for linked server "MYSQLLINK" returned
message "[MySQL][ODBC 5.1 Driver]Lost connection to MySQL server at
'waiting for initial communication packet', system error: 10060".
Msg 7303, Level 16, State 1, Line 4
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQLLINK".
Completion time: 2020-01-19T22:00:00.1759949-04:00
I am unsure why this is occurring, would appreciate if any could assist in figuring this out and helping in mitigating this error that will allow my view to be created and queried.
I've noticed if I comment out 85% of the joins the query does not fail. Where would I increase this time out the tome that is mentioned?
I should also mention that the MySQL is on an AWS server while the SQL Server is on my localhost.
I couldn't recreate the failure test case on my local-end, but what you mentioned directs us to following pointers:
Your linked server connection is getting timeout (probably)
Potential reason for timeout could be the high response time of query (view which joins quite a few reference tables)
What about changing the approach:
Can you create the view on MySQL rather than on SQL Server?
Is materialization of the result of the view is an option?
Or alternatively, what about writing a stored procedure on SQL Server-end and sequentially join your tables one-at-a-time (or as-many-reasonable-at-a-time) with use of temporary tables to store intermediate results?
I have a SQL statement running in SQL Server 2012 that sometimes works fine (returns a little over 4,000 rows in about 25 seconds) and sometimes fails after about 9 1/2 minutes with the error:
The OLE DB provider "MSDASQL" for linked server "Helpdesk" indicates
that either the object has no columns or the current user does not
have permissions on that object.
Here is the statement:
SELECT *
FROM OpenQuery(Helpdesk,
'SELECT ticketpostid,ticketid,dateline,userid,fullname,subject,editeddateline,contents,responsetime,staffid
FROM swticketposts
WHERE ticketpostid > 6609667'
)
Helpdesk is a Linked SQL that connects to a remotely located MySQL 5.5 server via an ODBC System DSN.
What are the possible causes of getting this error intermittently?
I have a table say Table1 on SQL Server 2014 and MySQL both.
Table1
ID INT,Code VARCHAR(100)
I created a linked server MyLinkedServer in SQL Server using "Microsoft OLEDB Provider for ODBC".
**Linked Server **
EXEC master.dbo.sp_addlinkedserver #server = N'MyLinkedServer', #srvproduct=N'MyLinkedServer', #provider=N'MSDASQL', #datasrc=N'MyLinkedServer'
EXEC master.dbo.sp_addlinkedsrvlogin #rmtsrvname=N'MyLinkedServer',#useself=N'False',#locallogin=NULL,#rmtuser=N'username',#rmtpassword='########'
Linked Server Settings
EXEC master.dbo.sp_serveroption #server=N'MyLinkedServer', #optname=N'data access', #optvalue=N'true'
EXEC master.dbo.sp_serveroption #server=N'MyLinkedServer', #optname=N'use remote collation', #optvalue=N'true'
EXEC master.dbo.sp_serveroption #server=N'MyLinkedServer', #optname=N'remote proc transaction promotion', #optvalue=N'true'
The linked server is created successfully and I am able to query Mysql Table in SQL Server.
Query
When I run
INSERT INTO MyLinkedServer...Table1(ID,Code) SELECT 1,'Code1'
The record is inserted. However when I start a transaction and run the INSERT, I get an error:
BEGIN TRAN
INSERT INTO MyLinkedServer...Table1(ID,Code) SELECT 1,'Code1'
COMMIT
Error:
OLE DB provider "MSDASQL" for linked server "MyLinkedServer" returned message "[MySQL][ODBC 5.3(a) Driver]Optional feature not supported".
Msg 7391, Level 16, State 2, Line 8
The operation could not be performed because OLE DB provider "MSDASQL" for linked server "MyLinkedServer" was unable to begin a distributed transaction.
What I have tried so far.
Enable XA Transactions in MSDTC
Enabled following setting in Linked Server Provider
Nested queries
Level zero only
Allow inprocess
Supports ‘Like’ Operator
I checked the following links and their suggestions however the error persists:
Distributed transactions between MySQL and MSSQL
SQL-Server and MySQL interoperability?
SQL Server and MySQL Syncing
EDIT
Additional Details:
MySQL is using InnoDB storage engine on Ubuntu machine.
I have already configured the ODBC connector and used it to configure a ODBC System Data Source which is used in the Linked Server
Theoretically this should work.
I would suggest different steps to sort this out:
Have you checked you MySql storage engine yet? It looks only InnoDB storage engine support distribute transaction per MySql document: https://dev.mysql.com/doc/refman/5.7/en/xa.html
See if you can switch to use MySQL Connectors setup connection to connect to MySql in SQL Server instead of OLEDB provider, which state by MySql document above that support distribute transaction.
If still not working, it might be the MSDTC service itself has some problem, see if you can isolate that like get a SQL Server instance running on the MySql server box(if you are using Windows MySql), or try install Windows MySql on the Sql Server box to get distribute transaction working between two MySql. Which would be able to point you to the actual problem.
EDIT:
Unfortunately it looks that you proved this not working, I've a closer look at the MySql document and sorry it looks that I wasn't reading it thoroughly, it says:
Currently, among the MySQL Connectors, MySQL Connector/J 5.0.0 and higher supports XA directly
And by some other Googling I found this: https://bugs.mysql.com/bug.php?id=37283, people report this bug many years ago and they marked this as a won't fix.
Some one suggested something here: https://social.msdn.microsoft.com/Forums/en-US/fc07937d-8b42-43da-8c75-3a4966ab95f9/xa-msdtc?forum=windowstransactionsprogramming, which is to implement your own XA-Compliant Resource Managers to be used by your application (https://msdn.microsoft.com/en-us/library/ms684317.aspx)
As on SQL 2014, you could have configured the linked server not to enlist in a distributed transaction. Although you could try adding "Enlist=false" in the #provstr argument to sp_addlinkedserver
Specs:
Sql Server 2008
Server 2008 R2 64bit
MS Access database
What works:
I have configured a Linked server connection to the Access database by installing office access data components and creating a system DSN and whatnot.
which resides in a directory on the same server.
I have succeeded in quering data through openquery.
SELECT * FROM OPENQUERY(LINKEDHELL, 'SELECT * FROM [D:\path\mordor.mdb].Orcs')
I can insert/update/delete through openquery (from inside the Sql Management Studio)
What does not work:
I have created a database which exposes a view that wraps the openquery expression. This allows my applications to remain oblivious to the fact thats its quering through an linked server connection and allows me to use an ORM. Case in point: Entity Framework.
However whilst retrieving data works, updating/inserting/delete wont.
I have spend quite some time making sure that the MSDTC is configured correctly however no dice.
What i tried
MSDTC
Enabled Network DTC Access
Allow Inbound/outbound
Configured Firewall
Enabled XA Transactions
Gave account under which DTC works access to the .mdb
Restarted Sql Server after making these settings
Other
Configured linked server security: Created mapping between sql user and local admin account, so that when i login with that sql user, it uses the local administrators account to connect to the access database.
Enable Promotion of Distributed Transactions for RPC : False
The error im getting:
OLE DB provider "MSDASQL" for linked server "LINKEDHELL" returned message "[Microsoft][ODBC Microsoft Access Driver]Invalid attribute/option identifier ".
Msg 7391, Level 16, State 2, Line 4
The operation could not be performed because OLE DB provider "MSDASQL" for linked server "LINKEDHELL" was unable to begin a distributed transaction.
I can simply recreate this by doing this from the Sql Management Studio
begin distributed transaction
//anything that queries the linked server
commit transaction
So what have I missed?
I have read that distributed transactions are supported by the ODBC driver, but im unsure if the ACCESS database does. So if someone could at the very least confirm that. That would help.
Access doesn't have transactions, because Access is not a database
engine. Jet/ACE (Access's default db engine) has supported
commit/rollback as long as I've used it (since Jet 2.x, e.g., 1996).
It has never supported transaction logging and probably never will (I
recognize that's not what you're asking about but many of those coming
to Jet/ACE from server database backgrounds are rather foggy on the
meaning of the term "transactions" and have a hard time grasping that
Jet/ACE supports one and not the other). – David-W-Fenton Jan 16 '10
at 23:12
-- Do we have transactions in MS-Access?
David W Fenton, MVP, RIP
I have a linked server in SQL Server 2008 that's using the MDASQL provider to access a Visual Fox Pro ODBC DSN.
I'm receiving the below errors when attempting to perform simple queries:
OLE DB provider "MSDASQL" for linked server "odbclinkedserver" returned message "[Microsoft][ODBC Visual FoxPro Driver]Not enough memory for file map.".
Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "MSDASQL" for linked server "odbclinkedserver" reported an error. The provider ran out of memory.
Msg 7306, Level 16, State 2, Line 1 Cannot open the table "odbctable" from OLE DB provider "MSDASQL" for linked server "odbclinkedserver".
I'm trying to run this update query that is the goal of the activity:
update odbclinkedserver...odbctable
set memofield = m1.blob
from sqlsvrtable m1
where m1.int_1 = odbctable.int_1
and m1.int_2 = odbctable.int_2
and m1.time= odbctable.time
and odbctable.date= '2011-06-28'
I have also attempted some simpler queries and still receive the same errors:
select top 1 * from odbclinkedserver...odbctable
The DSN source is a Free Table directory. The sizes of the files involved are:
odbctable.dbf = 62MB
odbctable.cdx = 9.85MB
odbctable.fpt = 200MB
I have configured the SQL instance to start with the '-g' parameter with a value of 1024 so that a gig of memory is set aside for this operation (this is a test server with no other activities).
Reference used: http://msdn.microsoft.com/en-us/library/ms190737.aspx
Given the size of the files involved, the simplicity of the queries, and that I've set aside a gig of RAM for it to use, I am running out of ideas of how to resolve this problem.
Can anyone suggest a solution to resolve these errors so that I can update the target dbf with the update query above?
Whilst you seem to have enough memory set aside when I had the same issue a stop and start of the SQL Server service followed by running sp_dropserver and sp_addlinkedserver was enough to resolve the issue:
IF EXISTS (SELECT srv.name FROM sys.servers srv WHERE srv.server_id != 0 AND srv.name = N'DBF_XXX')EXEC master.dbo.sp_dropserver #server=N'DBF_XXX', #droplogins='droplogins'
GO
EXEC master.dbo.sp_addlinkedserver #server = N'DBF_XXX', #srvproduct=N'Microsoft Jet', #provider=N'VFPOLEDB', #datasrc=N'D:\Data To Import\XXX\data', #provstr=N'dBASE 5.0'
--For security reasons the linked server remote logins password is changed with ########
EXEC master.dbo.sp_addlinkedsrvlogin #rmtsrvname=N'DBF_XXX',#useself=N'False',#locallogin=NULL,#rmtuser=N'Admin',#rmtpassword='########'
Make sure you're not violating any of VFP's ODBC restrictions in either the environment or the table structures. Especially note that ODBC hasn't been suported for some time. Check here for a good list of restrictions. Is using the OLEDB driver a possibility for you? If so do a web search for "VFPOLEDB driver download" to get what you need.