Mongo Cursor Exception: Timeout Waiting for Header Data - php

My company recently added MongoDB to the databases that we use and things have been going mostly smoothly, but every once in a while we get an odd error. It is near impossible to duplicate, and has only happened four times in the last week of testing, but once we go live to production our clients will be using the site much more frequently than we were for testing. We are trying to solve the bug before it gets out of hand.
The error we get is: (line breaks added for readability)
Fatal error: Uncaught exception 'MongoCursorException' with message
'Failed to connect to: 10.0.1.114:27017: send_package: error reading from socket:
Timed out waiting for header data' in
/opt/local/apache2/htdocs/stage2/library/Shanty/Mongo/Connection/Group.php on line 134
We are using ShantyMongo in PHP and it is a remote connection. The error is really intermittent, and refreshing the page is enough to get it to go away. As a temporary solution, we have wrapped all of our mongo methods in a for...try/catch so that if a MongoException is thrown we retry the method up to two more times, the hope being that it will succeed one of the three attempts since the error is so unpredictable.

Related

mysql howto find / debug error "mysqld got signal 11 ;"

Hope somebody can help here. We're running a MySQL Server (5.7.18-0ubuntu0.17.04.1), only a single application. A few clients connected pushing and pulling data from and into the database.
Sometimes, it goed all well for a long time... up to hours. Sometime, we're getting errors like
PHP Warning: mysqli::__construct(): (HY000/2002): Connection refused
or
PHP Warning: mysqli::query(): MySQL server has gone away
or
PHP Warning: mysqli::query(): Error reading result set's header
and
PHP Fatal error: Uncaught TypeError: Return value of mysqliConnection::escapeValue() must be of the type string, null returned
Errors above (At least the fatal errors), causes apache to exit with a 500-status-error. Not so good for our clients.
After searching, we found out all are mysql-related. Searching in the mysql-logs, gave us the mysqld got signal 11 ;. We're want to find out why this error / signal happens, but can't really find it. Tried a bunch of mysql-settings in my.cnf already, but doesn't seem to fix the issue.
See also these log-lines at pastbin: https://pastebin.com/GWDADudL
How can we find out what causes this error? Already used mysql.log to find out if it happens at a specific query, but seems to be random. Most tables are MyISAM, some InnoDB. Also had a MEMORY-table, but it's MyISAM now.
Help? Please? There seems to be something wrong, but what?

Errors destroying and reading sessions in PHP

I have a PHP 7 app that works well on all servers it's installed on except one. All servers are Windows (I believe server 2008 R2 and 2012). The problem is that on one of the servers, we keep getting two kinds of errors sporadically, seemingly randomly. One of the errors is
session_destroy(): Session object destruction failed
and the other is
PHP Fatal error: Uncaught exception 'ErrorException' with message 'Unknown: open(E:\tmp\sess_6qlo69vbii0qs65i4n47blafi3, O_RDWR) failed: Permission denied (13)' in Unknown:0
Every search I do on these errors go back to permissions, which makes sense aside from the fact that it's not happening every time, it's random. What am I missing here, could anything cause the permissions on the file to be different when the session gets created for some reason in certain situations? Or anything else that could possibly explain this behavior?

PHP/MongoDB Error: Uncaught exception 'MongoCursorException'

So i'm using MongoLab as my DB Host and recently I have been running into this issue. Whenever I load up my application for the first time with a cleared cache on the first run, I receive this error message:
Fatal error: Uncaught exception 'MongoCursorException' with message
'couldn't send query: Connection reset by peer'
After I refresh the page again and the application loads without any issues. I was wondering if anyone knew the reason for this error or had any fixes to resolve this.
Thanks and Happy Holidays.
Where are you hosting your app code?
What is likely happening is that the first connection is taking a while (longer than the set timeout) to connect to the MongoLab host. The connection is then established so that the second request uses it.

PHP: Implications of a abrupt termination of a request by a *fatal* error

I'm experiencing a strange situation.
My application logs lot of trace logs to a file. (I don't know exactly how, I use my frameworks logger. Can check this though)
Problems is, when an application is terminated by a fatal error (only fatal) [example - "Fatal error: Call to a member function someFunction() on a non-object"] , I end up with no logs, even logs that should have been recorded much earlier during the execution of my script.
(Yes, I tried to flush logs, this doesn't help either. It looks like the termination of the application by a fatal error, somehow cancels writing to files done at earlier points of the application.
Any ideas what goes on here?
Thank you
A Fatal Error is... well... Fatal : it stops the execution of the script, which will not do anything that should have been done.
In your case, I suppose your logging framework logs into memory -- and that this in-memory log is only written to the file when the processing of the request is done.
Some logging mecanisms do that, to avoid writing to a file several times, at different points during the generation of the response (which means keeping the file locked, to avoid concurrency problems ; or opening-closing-reopening-reclosing-... it)
As you get a Fatal Error, the normal operation that should be done at the end of the response's generation is not called -- and, so, the in-memory log is not written to the file.
Now, the only way to know for sure would be to take a look at the logging mecanisms of your Framework ;-)
Apparently, the fatality of the fatal error that Pascal mentioned, is not 100% fatal.
The below allowed me to have my logs even on fatal errors:
function correctShutdown()
{
logger->flush();
}
register_shutdown_function('correctShutdown');

Zend session_start gives Fatal error: Exception thrown without a stack frame in Unknown on line 0

When running a Zend application locally I get Fatal error: Exception thrown without a stack frame in Unknown on line 0, i traced that error to a line $startedCleanly = session_start();
I can't get through it, when I restart the server and reload the page I do not get the error, but on every other reload I get it, I looked into a php/tmp dir too see if there are any files, and as I see they aren't there. I think that session isn't written but when I try just a simple test.php file with session_start(); line, without zend framework, I see that there is a file created in that dir.
I really don't know where to go next.
Happens when your destructor or error handler throws an exception. That can happen for multiple reasons depending on your exact setup and method for session storage you're using. For example the session directory is not writeable or does not exist, database is not accessible or fields are invalid, redis does not respond, etc.
So, check your settings and look for something that would prevent saving the session data.
More elaborate description can be found here.
I know this post is old, but I've just figured out that I was getting "Fatal error: Exception thrown without a stack frame in Unknown on line 0" because my 'modified' and 'lifetime' columns were of type 'timestamp without time zone' when they should have been 'integer' (I'm using Postgres 9 BTW)
Hope this helps someone.
The problem could also be a disk full problem !!!

Categories