MySQL error - too many connections

Bug #1480698 reported by Sean M. Collins
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Roman Podoliaka
oslo.db
Invalid
Undecided
Unassigned

Bug Description

http://logs.openstack.org/59/138659/33/check/gate-tempest-dsvm-neutron-linuxbridge/29e7adc/logs/screen-n-api.txt.gz?level=ERROR

2015-07-21 11:29:53.660 ERROR nova.api.ec2 [req-522a314d-e88e-4982-b014-64141aeef73a tempest-EC2KeysTest-362858920 tempest-EC2KeysTest-451984995] Unexpected OperationalError raised: (_mysql_exceptions.OperationalError) (1040, 'Too many connections')

Tags: db network gate
tags: added: db gate network
Revision history for this message
Mike Bayer (zzzeek) wrote :

we see this in a lot of contexts downstream, and it turns out that based on load and such we do in fact need to raise the mysql_max_connections limit. Nova spawns a lot of Python processes, and each one can use anywhere from 1- 15 connections, 5 of which are persistently pooled.

I'm hearing on IRC that we're seeing it on Neutron as well and that the incidence of both seems to correspond. Basically, the source of the connections needs to be understood. I'd recommend using netstat to help figure it out, here's a line I used to identify individual processes:

    netstat -ntp | grep python | grep ESTABLISHED | grep 3306 | cut -c80-86 | sed 'sX/.*XX' | xargs -n1 ps -p | grep -v "CMD"

Revision history for this message
Sean M. Collins (scollins) wrote :

Most likely we need to tweak some settings my.cnf either in DevStack or DevStack-Gate.

Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :

Roman wrote a patch to gain more information: https://review.openstack.org/#/c/209858/

Changed in nova:
assignee: nobody → Roman Podoliaka (rpodolyaka)
Revision history for this message
Roman Podoliaka (rpodolyaka) wrote :

Yeah, I'm trying to figure out what's going on by periodically dumping information about connections to MySQL (https://review.openstack.org/#/c/209858/ - periodic task in nova-conductor).

I rechecked the patch multiple times - for most jobs the number of connections never exceeds ~150-200 units. So it's not clear to me how we actually managed to hit this problem (as in devstack the max connections number limit is set to 1024 - https://github.com/openstack-dev/devstack/blob/master/lib/databases/mysql#L99).

Curiously, according to logstash, there was another hit in the gate recently. But it was another Neutron job. I'm going to try something similar with Neutron too, as those jobs are only triggered on new changes to Neutron code.

Revision history for this message
Mike Bayer (zzzeek) wrote :

what can happen is if something deadlocks hard in the DB, the other processes would pile up on top of it waiting. Though I've never really seen MySQL have a permanent deadlock before.

Revision history for this message
Sean Dague (sdague) wrote :

This is not really a nova job, it's unsurprising that we see this in neutron jobs, there are more services, so more connections. Though now that we're using the pure python mysql driver we might not need such a high API worker count

Changed in nova:
status: New → Invalid
Revision history for this message
Mike Bayer (zzzeek) wrote :

worker counts IMO (and in others O) need to come way down across openstack services. esp the worker-per-core model, on a 24 core machine we see all kinds of services spinning up dozens of DB connections (b.c. they are pooled) and then just sitting idle.

Changed in oslo.db:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.