Bug #46596 Long connection delay
Submitted: 7 Aug 2009 0:00 Modified: 3 Jun 2012 1:41
Reporter: Miroslav Prikasky Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: General Severity:S5 (Performance)
Version:all OS:Other (OpenBSD (sparc64))
Assigned to: CPU Architecture:Any
Tags: Connection, Delay, long, OpenBSD, sparc64

[7 Aug 2009 0:00] Miroslav Prikasky
Description:
MySQL server version: 5.0.51 (OpenBSD package)
MySQL server configuration file: sample copy my-small.cnf from distribution without changes
OS: OpenBSD 4.3 GENERIC#1555 sparc64
HW: SUN Netra X1

Long connection delay when connection to the MySQL server running on OpenBSD 3.4 sparc64. Connecting to MySQL server takes average around 20 second, but it's variable. After connect to the server, SQL queries are fast. Problem is only with connection and it doesn't matter if I connecting through mysql.sock, localhost or client from LAN. The delay is same. This problem is significant on php web pages which uses DB and which it makes very slow, e.g. phpMyAdmin.
There is no error in the log file. DNS resolver is fast, --skip-name-resolve didn't help and I think there is no problem with network. There's propably something wrong only with sparc64 distribution. I have same configuration of OpenBSD 4.3 and same MySQL version but on different i386 architecture and without this problem.
I tried compile MySQL 4.1.22, 5.0.84, 5.1.36, 5.4.1-beta and 6.0.11-alpha from source but problem is same in all versions. I enabled ktrace logging for the mysqld process while I connecting to the server. The output dump file was recorded in less than a minute and is 1.1MB big.
The following segment is repeated 2768 times in the dump file.

  9344 mysqld   RET   poll 0
  9344 mysqld   CALL  sigreturn(0x476cf9b0)
  9344 mysqld   RET   sigreturn JUSTRETURN
  9344 mysqld   PSIG  SIGPROF caught handler=0x4e0ee9a0 mask=0x0
  9344 mysqld   CALL  gettimeofday(0x4e2f4060,0)
  9344 mysqld   RET   gettimeofday 0
  9344 mysqld   CALL  sigprocmask(0x3,0)
  9344 mysqld   RET   sigprocmask -65793/0xfffefeff
  9344 mysqld   CALL  poll(0x50594000,0x2,0)

How to repeat:
Connect to the MySQL server on OpenBSD 4.3 sparc64
[7 Aug 2009 0:02] Miroslav Prikasky
ktrace/kdump output

Attachment: mysqld-ktrace.out.gz (application/x-gzip, text), 6.74 KiB.

[7 Aug 2009 6:32] Valeriy Kravchuk
Thank you for the problem report. For me it looks related to http://bugs.mysql.com/bug.php?id=12061 and corresponding FreeBSD bug, http://www.freebsd.org/cgi/query-pr.cgi?pr=32295&cat=. Maybe something similar still happens to OpenBSD. Do you have any comments?
[7 Aug 2009 14:47] Miroslav Prikasky
For me it isn't looks related to previous FreeBSD bug, because there is no problem with CPU usage. If mysqld is idle CPU usage is 0%. If I connect to MySQL command line and execute some SQL queries mysqld CPU usage is not more than 10% and queries are fast. After disconnect mysql fall asleep and CPU usage is again 0%. During connection CPU usage looks normal but it is impossible to measure it because "top" process refresh every 5 seconds. This refresh make connection faster, it means not more than 5 seconds. It's anomalous but it is. If I execute infinity loop on server like this "while true; do uptime; done;" connection to MySQL afterwards isn't longer than 1 second. As I write in last post, I have absolutely same OpenBSD 3.4 and MySQL version on i386 without this problem. It looks like specific OpenBSD sparc64 problem.
[10 Aug 2009 9:45] Susanne Ebrecht
Just for my understanding:

You have this with MySQL CLI and with connection via PHP. Or is there a difference between connecting via CLI and via PHP connector?
[10 Aug 2009 15:31] Miroslav Prikasky
There is no difference between MySQL CLI via mysql socket, MySQL CLI via TCP/IP, PHP connector, Perl connector, MySQL Administrator or MySQL Query Browser. It is server side problem.
[3 May 2012 1:41] Miguel Solorzano
Please test with latest version. Thanks.
[4 Jun 2012 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".