ODBC Connection Dropping Frequently - mysql

Not sure what is going on....
MS Access front end (on Win7 and 10 PCs)
MySQL on DiskStation (MariaDB) back end.
Connection is through ODBC 5.3.
All was perfect and great until one day I lost internet service for about 2 hours. Once back up and running, we had a new dynamic IP. No problem. I changed the ODBC connection to the new IP and we're back up and running.
Then, a short time later, I start getting ODBC connection errors. Either "connection failed" or "gone away". Sometimes once a day, sometimes all machines (5 connections) randomly, many times throughout the day.
Sometimes if I just close and restart Access, the connection will enable. Sometimes it won't. Other times, I will "test" the ODBC driver and the first time it will fail, and the second time it will say "success", then all is well again.
Checked global wait timeout and it's set to 28800.
Since users connect both inside and outside of our LAN, the driver is set to our local IP, and then my Linksys router port forward 3806 to the internal IP of the DiskStation. Again, until Rogers dropped service and I was forced to use a different IP, all was well in our little network world.
Can anyone shed some light? Keep in mind, I am limited to my tech knowledge.

Related

Increase the amount of connections in my server MySQL

I have aplications that connect to a remote server (MySQL 5.5 on Windows Server 2012), at first I started receiving "too many connections" message which I solved by increasing MAX_CONNECTION value in my.inf to 500, then I start getting "can't create new thread" message so I decrease decrease timeouts to avoid idle connections using a socket, which didn't completely work. Now I get odd messages like 'file not found', as soon as I restart the service I stop getting the messages and everything works correctly.
The problem occurs when the server reaches around 170 connections at the same time.
Is there some configuration I'm missing?, I really don't know what info you need to give me a hint to fix this. I mean, there are servers that accept a lot morw of connections at the same time, right? waht I'm missing.
RAM and CPU of the system dosen't reach 35-40% at max connections (170).
Edit: Error occur at 2 'places', when running a query or at the attempt of conennection, it's like the MySQL service rejects the attempt. VB6 is the language used in the client app (ODBC connector). The app opens, executes and closes the connection.
Note: I have full control over client app and server config.

Intermittent 2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0" to CloudSQL

I setup an old Django app on a new GCE instance on Sunday and pointed it to a new CloudSQL instance with imported data there. This code and data has successfully run over the past few years on a variety of dedicated hosting setups, on EC2 and on EC2+RDS.
Since Sunday I have had intermittent reports of 2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0" from the App. In particular today it happened in two bursts of 3 separated by about 7 hours.
I panicked in the earlier outages and restarted both the app and the CloudSQL instance which did the trick. However the latter ones today righted themselves after a few minutes.
I've never encountered this error before working with MySQL and any searching on the error gives results related to people who have general access problems to the DB.
On the GCE side the only difference I can think of from previous setups is that it is using Google's out-of-the-box Debian image instead of Ubuntu 12.04. On the MySQL side I have no idea as I've successfully run this on both MySQL 5.x and MariaDB.
Is there any way of figuring out why this is happening and fixing it?
Thanks.
Have you tried changing keep alive settings for TCP connections? GCE has a firewall rules that drops idle TCP connections after 10 mins:
https://cloud.google.com/compute/docs/troubleshooting#communicatewithinternet
You can check current value of 'tcp_keepalive_time':
cat /proc/sys/net/ipv4/tcp_keepalive_time
And change it to 60 seconds:
vi /etc/sysctl.conf
# Add this line
net.ipv4.tcp_keepalive_time = 60
# Reload Sysctl interface
sudo /sbin/sysctl --load=/etc/sysctl.conf
You might need to restart Django server to pick new keep alive settings.
Note: If this problem was limited to yesterday (18/11/2014) and your Cloud SQL instances are located in EU, you might have been affected by this:
https://groups.google.com/forum/#!topic/google-cloud-sql-announce/k5raPT48hc0
It seems there is an issue with the firewall, preventing incoming connections, just change the location from the server to another mirror things suppose to go fine. It worked for me

Intermittently can't connect to mysql on AWS RDS (Error 2003)

We are having an intermittent issue with connections to our mysql server timing out.
The error we are receiving is as following.
(2003, 'Can\'t connect to MySQL server on \'<connection>\' ((2013, "Lost connection to MySQL server during query (error(104, \'Connection reset by peer\'))"))')
Callstack:
File "/usr/lib64/python2.7/site-packages/pymysql/connections.py", line 818, in _connect
2003, "Can't connect to MySQL server on %r (%s)" % (self.host, e))
File "/usr/lib64/python2.7/site-packages/pymysql/connections.py", line 626, in __init__
self._connect()
Some more info:
We have a flight of EC2 servers that are constantly running queries to a backend RDS.
We average about 500 connections per second to the RDS
We have around 0 - 4 hiccups per RDS per day
The hiccups don't correspond with our maintenance window
When we hit a hiccup it can affect quite a few connections ~50
When a hiccup happens it will disrupt connections across all servers and ports
The error itself looks to be generated from the tcp connection being closed on the ec2. Our TCP keep alive time is set to 7200 seconds and that's when the error is fired off.
My question is what can be done to track down why these hiccups happen? It's great that they don't happen often, but it's not ideal that they happen at all.
Any advice would be appreciated thanks!
Update 10/29:
I've been running a service checking to see if I have any long processes running on the sql server and it looks like these errors aren't getting that far. A new process is never created for this connection! I have still been receiving the hiccups, just no signs of connections.
So after a back and forth with amazon support here is the current solution we have come to.
Amazon has raised our socket listen backlog by adjusting the somaxconn value on the RDS instance.
The value was at the default of 128 and has been bumped up to 1024.
Once the value was adjusted we no longer received the Lost Connection error.

PHP MySQL Connection Timed Out on private network

I am getting intermittent 'Connection Timed Out' errors when a php script on my web server connects to the MySQL database server over the private network. However, if I tell the script to use the public network to connect, these errors do not appear.
My connection script is setup so that whenever I try to connect to mysql, it checks for errors, if there is an error, it sends me an email then automatically switches to the public network to try that connection. If the public connection fails, it sends me another email and displays a custom web page to the user.
I get about 5 to 10 connection errors every hour. There are hundreds of successful connections every minute.
These machines are dedicated machines. I contacted our hosting company and they tested the routers and cables and said everything is fine. I tried pinging the servers both ways and there are no errors at all for test periods over an hour.
I am using the latest Nginx with the latest PHP and PHP-FPM. Mysql is 5.5.27. These are Centos 6 64bit systems with that latest updates.
I've tried many network configuration options, adjustments to php-fpm & mysql config file and no matter what I do or change, nothing fixes it.
The weird thing is, everything works great over the public network and pings and file transfer work great over the private network between both machines.
Any ideas?
** UPDATE **
I made some changes to the PHP-FPM config file and to the MySQL config file and the errors are now about 2 to 3 per hour but still unresolved.
I'm not sure this is your case but still worth mentioning as it helped me in a similar situation. Basically, there is a cap on max number of connections in linux kernel: https://serverfault.com/questions/10852/what-limits-the-maximum-number-of-connections-on-a-linux-server
Not sure if it is shared between all the networks, but if you think it's worth checking I'd just raise those variable values say twice and see if it had any effect on how frequently the error happens.

Hard to debug "Mysql server has gone away"

I'm running a MsAccess with Mysql background database and today I am experiencing some problems.
Depending on how far I can get into the program I am able to get a list of all the names and entry. But once I go into the edit form of any entry I get a variety of results. Sometimes I am lucky and I can see the first entry. But any entry after that will always get a MsAccess error: Object invalid or no longer set and then any subsequent calls after will yield a Mysql ODBC error of Mysql server has gone away.
I've looked around at several websites and even all the stack overflow sites with the same question and I've tried a variety of solutions. (Keep in mind that this database has been running for years and this is the first time I am getting this message) It also takes about 2m14s to 2m59s before it displays any error messages.
Here is what I tried so far:
I've tried changing a few of the ODBC connection settings.
Checked Allow Big Results - FAILED
Checked Enable Auto Reconnect - FAILED
I've Checked and repaired tables - FAILED
A good number of tables resulted in, "table needs update please repair table"
I've Doubled the numbers in the my.cnf configuration and restarted the mysql service as well as the msaccess software. FAILED
These were the settings of my my.cnf after I made the changes.
Here:
set-variable = max_connections=500
safe-show-database
log-error=/var/log/mysqld.log
connect_timeout=1000
interactive_timeout=28800
wait_timeout=288000 <**This was changed**
join_buffer_size=6M
key_buffer_size=300M <**THIS WAS CHANGED **
max_allowed_packet=300M <**THIS WAS CHANGED **
myisam_sort_buffer_size=300M <**THIS WAS CHANGED **
read_buffer_size=6M
sort_buffer_size=6M
table_cache=12288
thread_cache_size=24
tmp_table_size=132M
query_cache_limit=3M
query_cache_size=64M
query_cache_type=1
Basically I've tried every suggestion I could find so far and I can't seem to figure out the problem.
I've also had a look at MYSQL: Has gone away
If I go through the bulleted list there
Nobody has killed the running thread
I don't think the query was ran after the connection was closed (since it ran for years fine)
Client application does have the privileges needed
I don't know how to figure out if I had a timeout from the TCP/IP connection on client side
I don't know if I've encounted a timeout on the server side, but I do know that automatic reconnection in client is disabled
???
The query could potentially be large since it is a form with many subforms
???
DNS should be ok, since I can connect to it with a real sql viewer (HeidiSQL)
???Child forks???
???
I think this is one of those bugs that is hard to figure out since I'm exhausted :/ I'm probably missing some info but I am not sure what else to include.
---EDIT---
Thank you all for your comments, I'm still debugging this issue. It seems that it's not all the forms that are causing some issues. So I'm starting to think that this is a MSAccess issue more than it is an MySql issue. The forms that do break all have the same line in their VBA code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If Screen.ActiveControl.Name = "UnboundTextBox" Then
Response = acDataErrContinue
End If
End Sub
I don't recall putting this code in, so I assume it's an automatic thing, but I'm still going through all my forms to see which ones cause this error and which do not. So more in a few.
---Today I'm doing some debugging trying to find whatever I can from whatever log I can muster ----
MSACCESS 17ec-b10 EXIT SQLStatisticsW with return code -1 (SQL_ERROR)
HSTMT 0AF82920
WCHAR * 0x00000000 [ -3] <empty string>
SWORD -3
WCHAR * 0x00000000 [ -3] <empty string>
SWORD -3
WCHAR * 0x0013AAE8 [ -3] "location\ 0"
SWORD -3
UWORD 1 <SQL_INDEX_ALL>
UWORD 0 <SQL_QUICK>
DIAG [08S01] [MySQL][ODBC 3.51 Driver][mysqld-5.0.92-community]Lost
connection to MySQL server during query (2013)
----------------------------- FINAL EDIT --------------------------
The past week or so, my boss has been working hard to install a new internal server for our office. We also switched IPs several times and ISP providers. Turns out, as a result he created for me an administrative nightmare, as I attempted to debug issues with the server, and issues with the software ect.. ect.. when the issue was in the settings the ISP providers established with the router settings etc... etc... SO basically this whole headache was nothing wrong with server, nor software but hardware inbetween.
So now, I have to backwards engineer everything I did and try to get it to work on both ips. It works on the important one now. But it's not working on the old one so... I guess I just have to figure that out. [Waving imaginary fist in the air] Lol
The problem is that the connection is timing out. This is not a setting that you can change at the ODBC level. My MySQL provider had set the timeout at 30 seconds (you can find out what yours is set at my running the PassThrough query "SELECT ##wait_timeout"). I got round it by polling the connection every 10 seconds with a simple form. That keeps the connection alive. Make sure you have an AutoExec macro which opens the form.
Private Sub Form_Open(Cancel As Integer)
Me.TimerInterval = 1000 ' 10 seconds
End Sub
Private Sub Form_Timer()
Me.Requery
End Sub
I have not used MySQL with Access in a production environment, but the problem you are having sounds suspiciously similar to one I've encountered with SQL Server. Basically, if the client workstation has incorrect DNS settings, it can get confused about how to resolve the connection to the SQL Server and lose the connection. In the cases where I've encountered this, the workstations were incorrectly configured with the Internet provider's DNS as primary DSN, but the SQL Server was a local server, available only on the local LAN (and not mapped by the ISPs DNS).
The solution is to use the local domain controller as the primary DNS. It will look up the local SQL Server's IP and pass off any non-local lookups to the Internet provider's DNS.
If you don't have a Windows/Samba domain controller, then you need to use whatever the local LAN's authorative name server is. Alternatively, you could connect to the MySQL server by IP address and avoid the problem, or map it in the client workstation's HOSTS file (which is not recommended -- it's a great way to cause really hard to troubleshoot problems when the IP addresses change).
[mysqld-5.0.92-community]Lost
connection to MySQL server during query (2013)
This genary means you have found a bug in MySQL-Server
can you post a tail of your mysqld.err and mysqd.log
this makes the server restart and will effectefly shut down all open connections