Empty PDO Calls

44 views
Skip to first unread message

DS33511

unread,
Nov 21, 2018, 10:43:19 AM11/21/18
to Fat-Free Framework
Hi All,

I'm hoping someone may have run into this at some point as I've been unable to find any info online about it. We run an F3 app in an AWS Elastic Beanstalk environment without a local DB instance configured. The DB resides in RDS.

That said, I periodically get alarms that correspond to the following errors in the error log:

[Wed Nov 21 07:25:58.290266 2018] [:error] [pid 18334] [client XXXXXXXXXXXXXX] SQLSTATE[HY000] [2002] No such file or directory [/var/app/current/lib/db/sql.php:505]
[Wed Nov 21 07:25:58.290315 2018] [:error] [pid 18334] [client XXXXXXXXXXXXXX] [lib/db/sql.php:505] PDO->__construct()
[Wed Nov 21 07:25:58.290320 2018] [:error] [pid 18334] [client XXXXXXXXXXXXXX] [classes/Controller.php:133] DB\\SQL->__construct()
[Wed Nov 21 07:25:58.290322 2018] [:error] [pid 18334] [client XXXXXXXXXXXXXX] [index.php:43] Base->run()

And controller.php:133 snip looks like:

 $f3->set('DB', new \DB\SQL( 'mysql:host='.$f3->get('DBHOST').';port='.$f3->get('DBPORT').';dbname='.$f3->get('DBNAME'), $f3->get('DBUSER'), $f3->get('DBPASS'), array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION) ));

The vars DBHOST, DBPORT, etc... are coming from /config/config.ini file and work without issue 99% of the time.

It seems as though something is trying to instantiate a PDO object with no params. This is much more noticeable overnight when traffic is very low, so the alarm trips due to the percentage of failed requests.

Currently running F3 version 3.6.1

If anyone has any insight it would be greatly appreciated. Thank you!

ved

unread,
Nov 21, 2018, 11:54:30 AM11/21/18
to Fat-Free Framework
It seems as that is kind of a common issue when using PDO on AWS as can be seen by this query.

It appears as the mysql host and/or socket isn't being found by the PDO class.

Maybe Amazon "spins down" the mysql server on low traffic periods and then when somebody tries to connect, the spin-up time is longer than the connection timeout so it thinks the mysql server is gone. Does this issue happen several times in a row, or only once occasionally?

Also, have you tried it with the latest F3 version?

DS33511

unread,
Nov 21, 2018, 12:44:26 PM11/21/18
to Fat-Free Framework
Thanks Ved. It seems to be happening at random times, sometimes several times within a 10 second period. It also happens during periods of high traffic.

The requests are coming from the load balancers, so I'm starting to think this may be related to health check requests over port 80. I will do some more digging and post what I find, if anything.

And I have not yet tried with the latest F3 version. I will be upgrading soon and see if that has any effect.

ved

unread,
Nov 21, 2018, 2:03:32 PM11/21/18
to Fat-Free Framework
No problem.
Also, you can try opening a support ticket with Amazon and see if they can shed some light into the issue. As it appears to be somewhat common, maybe they already have some sort of solution.
Good luck.

Richard Goldstein

unread,
Nov 21, 2018, 3:43:36 PM11/21/18
to ved via Fat-Free Framework, Fat-Free Framework
Have you tried creating a specific path for the health checks? (I do this) I would create one that does not open a db connection to see if it solves the problem


--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/3bf7a92e-087b-4df0-8c27-03e6de30125a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Rich Goldstein, MD

Antonio Diaz

unread,
Apr 11, 2020, 4:01:34 PM4/11/20
to f3-fra...@googlegroups.com

It just happen to me on a mac, 

For the record, it's macOS 10.15.4 aka macOS Catalina


#       Order allow,deny

#       Allow from All

        Require all granted


you need to add "Require all granted", but back to the point, I got the same 


SQLSTATE[HY000] [2002] No such file or directory [/var/app/current/lib/db/sql.php

Then I created a different php file to test the PDO connection and same issue, so it was not F3. 
Started reading and somebody ran "php -i | grep sock" ( same response as phpinfo() ). The mysql.sock file create by default is in "/tmp/mysql.sock" but the PHP is looking at "/var/mysql/mysql.sock" so, because I couldn't find "my.cnf" then..

I created "/var/mysql" directory and soft linked to the "/tmp/mysql.sock". 
Ran the little script again, It worked!, 
Reloaded my index.php and it worked on F3!.

For some reason, my PHP default installation on my mac does not have a php.ini, and the mysql default does not have my.cnf file. weird!

It's not a F3 problem, is a mysql-php problem. Thought it was ok to share with you guys.


Antonio
Reply all
Reply to author
Forward
0 new messages