framework icon indicating copy to clipboard operation
framework copied to clipboard

STMT_PREPARE

Open yuchen99 opened this issue 11 years ago • 2 comments

Hi gays I have a daemon script when I run it frist time it run works but after an night I get this message

"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Uncaught exception 'Illuminate\\Database\\QueryException' with message 'Error while sending STMT_PREPARE packet. PID=5724 (SQL: select * from `resourc
e_services` where `id` = 5 limit 1)' ...........................................```

I try add this code 
```PHP
try {
            DB::connection()->getDatabaseName();
        } catch (Exception $e) {
            echo $e->getMessage();
            DB::reconnect(Config::get('database.default'));
        }

But it not work .what this problem mean?

yuchen99 avatar Jan 06 '15 02:01 yuchen99

Ensure your script is reconnecting to the database every once in a while...

The database connection is probably stalled for being open for so long.

BTW, This is not related to Laravel.

ibrasho avatar Jan 06 '15 16:01 ibrasho

@ibrasho I'm having this same problem (Error while sending STMT_PREPARE packet. PID=*), and I've seen this same suggestion (in a couple other posts... e.g. the edit at the top) about forcing a reconnect to the MySql database, but I don't understand it. It "feels" like it shouldn't be necessary.

Why would I ever need to write in my code that it should reconnect to the DB? It seems like that would be a band-aid rather than identifying and addressing the root cause.

Am I missing something? Thanks.

ryancwalsh avatar Nov 23 '18 15:11 ryancwalsh