Drupal 7 PDOException: (possibly a max_packet_size issue?) - mysql

After saving a View i got this error come up on all pages in Drupal 7. After some research i think it's a problem with the "max allowed packet" in Mysql being set too low...currently 68MB. I have requested it be set to 250MB. But any further diagnosis of the problem would be welcomed.
Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT format, type, language FROM {date_format_locale}; Array ( ) in system_date_format_locale() (line 3650 of /home/mysite/public_html/beta1/modules/system/system.module).
Additional
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:132:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT format, type, language FROM {date_format_locale}; Array ( ) ";s:9:"%function";s:27:"system_date_format_locale()";s:5:"%file";s:61:"/home/mysite/public_html/beta1/modules/system/system.module";s:5:"%line";i:3650;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://beta1.mysite.co.uk/ [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => 83.244.234.228 [:db_insert_placeholder_9] => 1352306457 ) in dblog_watchdog() (line 157 of /home/mysite/public_html/beta1/modules/dblog/dblog.module).
Uncaught exception thrown in session handler.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in _drupal_session_write() (line 206 of /home/mysite/public_html/beta1/includes/session.inc).
thanks
lee

In order to fix this issue the guys at PlatinumServerManagement.com increased the wait-timeout value in mysql configuration file.
Lee

Related

SQL/Laravel is not quoting text fields when building a query

UPDATED
I am new to Laravel and tried to test this demo https://github.com/laravel-json-api/laravel on my local Mac after installing ddev, Docker and MAMP. The problem is that the code (that I didn't write, I just downloaded without making any changes) is executing a SELECT trying to find a user with that email address but, apparently, Laravel builds the SQL sentence removing the quotes when adding the content for the field "email".
This is the error message that I get on the browser:
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `users` where `email` = frankie#example.com limit 1)
I use MySQL 5.7.32 and the DB collation is utf8_general_ci.
The error show in the browser when the exception is caught is:
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php
* #param array $bindings
* #param \Closure $callback
* #return mixed
*
* #throws \Illuminate\Database\QueryException
*/
protected function runQueryCallback($query, $bindings, Closure $callback)
{
// To execute the statement, we'll simply call the callback, which will actually
// run the SQL against the PDO connection. Then we can calculate the time it
// took to execute and log the query SQL, bindings and time in our memory.
try {
$result = $callback($query, $bindings);
}
// If an exception occurs when attempting to run a query, we'll format the error
// message to include the bindings with SQL, which will make this exception a
// lot more helpful to the developer instead of just the database's errors.
catch (Exception $e) {
throw new QueryException(
$query, $this->prepareBindings($bindings), $e
);
}
return $result;
}
/**
* Log a query in the connection's query log.
*
* #param string $query
* #param array $bindings
* #param float|null $time
* #return void
*/
public function logQuery($query, $bindings, $time = null)
{
$this->event(new QueryExecuted($query, $bindings, $time, $this));
if ($this->loggingQueries) {
*Arguments
"SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `users` where `email` = frankie#example.com limit 1)"*
This is the database.php config for the demo project:
database.php demo:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '8889'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
],
MySQL listens on port 8889
Anyone has experienced a similar situation?
Thanks
Your problem is not the quotes, there's something wrong with the SQL server internally.
Regarding the quotes:
When using the standard eloquent methods, query parameters will be sent to the server using prepared statements. This is very save and the no need four adding quotes. Internally the server handles the parameters correctly.
Whenever an error occurred, the server outputs the pure, unquoted data of received from the prepared statement. This indeed is a bit misleading, but it's not an error.
I closed this question as it is not related to how Laravel builds the SQL sentence. It is about an error trying to connect to MySQL from any PHP code on MAMP. See my new question here Error: 200 Connection refused on PHP connecting to MySQL running on MAMP
Such an error may occur when accidentaly we are passing in fields that don't match our Model's fields

Prestashop: 'Link to database cannot be established'

This is our first time moving a Prestashop Installation from one Domain to another and it has been one hell of a learning curve.
Steps we have taken so far:
Copied the database:
0) New database name: gamingco_ps, user gamingco_ps1
Changed ps_configuration
Changed the ps_shop_url (Domain/Domain SSL)
Amended htcacess to stop any redirects
CPANEL removed all temporary redirects
Changed the /home/gamingco/public_html/app/config/parameters.php :
<?php return array (
'parameters' =>
array (
'database_host' => 'localhost',
'database_port' => '',
'database_name' => 'gamingco_ps',
'database_user' => 'gamingco_ps1',
'database_password' => '{Password}',
'database_prefix' => 'pswy_',
'database_engine' => 'InnoDB',
'mailer_transport' => 'smtp',
'mailer_host' => '127.0.0.1',
'mailer_user' => NULL,
'mailer_password' => NULL,
'secret' => 'dva3atuoqjpqhb8xmjtfwjszkpbwaifombdlbg46qwygbi7e4mpyfgui',
'ps_caching' => 'CacheMemcache',
'ps_cache_enable' => false,
'ps_creation_date' => '2021-01-27',
'locale' => 'en-US',
'use_debug_toolbar' => true,
'cookie_key' => 'zml9yqgynwgixtb1e4c0xh8q8gjeynsp7arnovqw5dhpcthcyfpu89bx',
'cookie_iv' => 'qsembkbmpfbnk5bf3hhxjg3sw1laaa06',
'new_cookie_key' => 'def00000acce4699cd116debb37dc5533dfd6ff201153a61ac3446801d772207548a0f44596a7a01939e9f753e4290f3735373a25516e62b2118322ec7f7cd64e3b347ee',
),
);
We are now receiving error 500 without debug mode and with debugmode we are met with:
Link to database cannot be established: SQLSTATE[28000] [1045] Access denied for user 'gamingco_ps1'#'localhost' (using password: YES)
at line 136 in file classes/db/DbPDO.php
131. public function connect()
132. {
133. try {
134. $this->link = $this->getPDO($this->server, $this->user, $this->password, $this->database, 5);
135. } catch (PDOException $e) {
136. throw new PrestaShopException('Link to database cannot be established: ' . $e->getMessage());
137. }
138.
139. $this->link->exec('SET SESSION sql_mode = \'\'');
140.
141. return $this->link;```
DbPDOCore->connect - [line 330 - classes/db/Db.php]
DbCore->__construct - [line 241 - classes/db/Db.php] - [4 Arguments]
DbCore::getInstance - [line 47 - config/alias.php]
pSQL - [line 1336 - classes/shop/Shop.php] - [1 Arguments]
ShopCore::findShopByHost - [line 337 - classes/shop/Shop.php] - [1 Arguments]
ShopCore::initialize - [line 118 - config/config.inc.php]
require - [line 27 - index.php] - [1 Arguments]
I gone through all the steps again and I cannot seem to identify where the error maybe.
Error is pretty straighforward here, Prestashop cannot connect to database.
Things to check:
Make sure your var/cache/prod directory does not contain any cache file from previous installation as it can lead to old DB connection with old credentials.
Double check DB data in parameters.php, carefully look for data correctness (case sensitive, correct DB host / port etc.)
If none of above helps, try connecting your box from ssh and check direct db connection from there with :
mysql -u{username} -p{password} {database name}
and post the result.

Use of undefined constant SIGKILL - assumed 'SIGKILL' in Laravel 5.7 queue

I'm getting this error "Use of undefined constant SIGKILL - assumed 'SIGKILL'" from my AJAX request, that starts this artisan command ->
Artisan::call('queue:work', [
'connection' => 'database',
'--memory' => '700',
'--tries' => '1',
'--timeout' => '35000',
'--queue' => 'updates'
]);
I'm using Laravel 5.7 as framework for application.
Jobs are managed from database, configuration ->
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 18000,
],
Problem appeared recently.. That is weird, because troubles wasn't here before and all this "system" worked just fine. Now worker get some jobs done just fine, but then it drops to error, and writes to table "failed_jobs" in DB this ->
ErrorException: PDOStatement::execute(): MySQL server has gone away in /srv/migration-xxxxxx-xxxx-xxxxxx/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
As DB I'm using Microsoft Azure MySQL DB. Microsoft specialist after consultation find nothing .. server is working correctly. Queries are just fine, not that big to fail.
Please help, don't know what to do, or what is wrong...

Drupal 7: SQLSTATE[23000] ERROR after installing module

after installing and activating "filter_harmonizer" I get the following SQL-error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'bartik-views-standorte-block' for key 'tmd': INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => views [:db_insert_placeholder_1] => standorte-block [:db_insert_placeholder_2] => bartik [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => -1 [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => -1 ) in drupal_write_record() (line 7166 of /is/htdocs/xyz/www/meineseite/includes/common.inc).
Now there is only one node displayed, the others couldn't be found by drupal.
On the admin pages there is the following error shown:
no administrationobjects available
Can anyoune help me how to solve the problem? I'm not an SQL-crack, so I need a bit more help.
Thanks a lot!

drupal views module mysql error

i have enabled the view module and get this when i go to structure>views in drupal 7
Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {cache_form} WHERE (cid = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => form_form-MKcd7j8VJkLHaG7-JGW-vREo_XeUngdnLcqlKOn-02o ) in cache_clear_all() (line 170 of /home/tennis/public_html/includes/cache.inc).
Additional
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:240:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {cache_form} WHERE (cid = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => form_form-MKcd7j8VJkLHaG7-JGW-vREo_XeUngdnLcqlKOn-02o ) ";s:9:"%function";s:17:"cache_clear_all()";s:5:"%file";s:43:"/home/tennis/public_html/includes/cache.inc";s:5:"%line";i:170;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://192.168.1.66/~tennis/admin/structure/views [:db_insert_placeholder_7] => http://192.168.1.66/~tennis/user/1 [:db_insert_placeholder_8] => 192.168.1.172 [:db_insert_placeholder_9] => 1309366098 ) in dblog_watchdog() (line 155 of /home/tennis/public_html/modules/dblog/dblog.module).
what maybe my issue?
Here is some information on that error: http://dev.mysql.com/doc/refman/5.1/en/gone-away.html and a similar issue on Drupal.org: http://drupal.org/node/984112
Another helpful post regarding this error: http://madhavvyas.blogspot.com/
It seems that the problem lies with max_allowed_packet in the configuration for MySQL.
From the Drupal issue, another user provides some steps that may assist you (this user is using XAMPP but steps are similar):
How to fix this problem
Go to xampp\mysql\bin
Open my.ini
Change "max_allowed_packet" from "1m" to "16m" (or larger)
Save my.ini Now restart MySql through the XAMPP control panel.