MySQL server has gone away

I’m suddenly getting this error every time I try to edit an item and save. I’m concerned that I’ve irrevocably ruined the database.

Initially I tried to tweak my ImageMagick (policy.xml) config to process some larger jpeg images and that worked for my test Omeka installation. Then switched over to my production environment and started receiving the error and MariaDb restarts every time. The test installation continues to work fine on the same server, so at least the database server should be okay.

Is there any way to debug what Omeka is trying and failing to write to the database?

Here’s the output in the application.log and mysql.log below

2023-02-22T22:28:20+00:00 ERR (3): PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /opt/bitnami/apache/htdocs/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connecti     on.php:1842
Stack trace:
#0 /opt/bitnami/apache/htdocs/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1842): PDO->rollBack()
#1 /opt/bitnami/apache/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(457): Doctrine\DBAL\Connection->rollBack()
#2 /opt/bitnami/apache/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(376): Doctrine\ORM\UnitOfWork->commit()
#3 /opt/bitnami/apache/htdocs/application/src/Stdlib/FulltextSearch.php(43): Doctrine\ORM\EntityManager->flush()
#4 /opt/bitnami/apache/htdocs/application/Module.php(568): Omeka\Stdlib\FulltextSearch->save()
#5 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Omeka\Module->saveFulltext()
#6 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-eventmanager/src/EventManager.php(170): Laminas\EventManager\EventManager->triggerListeners()
#7 /opt/bitnami/apache/htdocs/application/src/Api/Manager.php(323): Laminas\EventManager\EventManager->triggerEvent()
#8 /opt/bitnami/apache/htdocs/application/src/Api/Manager.php(269): Omeka\Api\Manager->finalize()
#9 /opt/bitnami/apache/htdocs/application/src/Api/Manager.php(136): Omeka\Api\Manager->execute()
#10 /opt/bitnami/apache/htdocs/application/src/Mvc/Controller/Plugin/Api.php(152): Omeka\Api\Manager->update()
#11 /opt/bitnami/apache/htdocs/application/src/Controller/Admin/ItemController.php(245): Omeka\Mvc\Controller\Plugin\Api->update()
#12 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(77): Omeka\Controller\Admin\ItemController->editAction()
#13 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\Controller\AbstractActionController->onDispatch()
#14 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners()
#15 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(103): Laminas\EventManager\EventManager->triggerEventUntil()
#16 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-mvc/src/DispatchListener.php(139): Laminas\Mvc\Controller\AbstractController->dispatch()
#17 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\DispatchListener->onDispatch()
#18 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners()
#19 /opt/bitnami/apache/htdocs/vendor/laminas/laminas-mvc/src/Application.php(331): Laminas\EventManager\EventManager->triggerEventUntil()
#20 /opt/bitnami/apache/htdocs/index.php(21): Laminas\Mvc\Application->run()
#21 {main}
2023-02-22 15:45:43 13 [ERROR] InnoDB: (Duplicate key) writing word node to FTS auxiliary index table `tphistory`.`fulltext_search`
2023-02-22 15:45:43 0x7f99a01f4700  InnoDB: Assertion failure in file /bitnami/blacksmith-sandox/mariadb-10.6.9/storage/innobase/que/que0que.cc line 728
InnoDB: Failing assertion: trx->error_state == DB_SUCCESS
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to https://jira.mariadb.org/
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mariadbd startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: https://mariadb.com/kb/en/library/innodb-recovery-modes/
InnoDB: about forcing recovery.
230222 15:45:43 [ERROR] mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.

To report this bug, see https://mariadb.com/kb/en/reporting-bugs

We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.

Server version: 10.6.9-MariaDB
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=1
max_threads=153
thread_count=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467959 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7f9978001448
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7f99a01f3e18 thread_stack 0x49000
??:0(my_print_stacktrace)[0x55f8004416fe]
??:0(handle_fatal_signal)[0x55f7fff781f5]
??:0(__restore_rt)[0x7f99abc84140]
??:0(gsignal)[0x7f99ab7a1ce1]
??:0(abort)[0x7f99ab78b537]
??:0(Wsrep_server_service::log_dummy_write_set(wsrep::client_state&, wsrep::ws_meta const&))[0x55f7ffc374bb]
??:0(Wsrep_server_service::log_dummy_write_set(wsrep::client_state&, wsrep::ws_meta const&))[0x55f7ffc23d0c]
??:0(void std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long&&))[0x55f8003c9dd9]
??:0(void std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long&&))[0x55f8003b904f]
??:0(void std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long&&))[0x55f8003bd5b4]
??:0(void std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long&&))[0x55f8003beec6]
??:0(void std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long&&))[0x55f8003bf085]
??:0(void std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long&&))[0x55f8003bf246]
??:0(main)[0x55f7ffc9381e]
??:0(void std::this_thread::sleep_for<long, std::ratio<1l, 1l> >(std::chrono::duration<long, std::ratio<1l, 1l> > const&))[0x55f800333cef]
??:0(void std::this_thread::sleep_for<long, std::ratio<1l, 1l> >(std::chrono::duration<long, std::ratio<1l, 1l> > const&))[0x55f800333e32]
??:0(wsrep_notify_status(wsrep::server_state::state, wsrep::view const*))[0x55f800251450]
??:0(wsrep_notify_status(wsrep::server_state::state, wsrep::view const*))[0x55f800251542]
??:0(wsrep_notify_status(wsrep::server_state::state, wsrep::view const*))[0x55f800251673]
??:0(ha_check_and_coalesce_trx_read_only(THD*, Ha_trx_info*, bool))[0x55f7fff7b8b6]
??:0(ha_commit_trans(THD*, bool))[0x55f7fff87d8b]
??:0(trans_commit(THD*))[0x55f7ffe781e3]
??:0(mysql_execute_command(THD*, bool))[0x55f7ffd69050]
??:0(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x55f7ffd6b2a8]
??:0(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x55f7ffd6cea5]
??:0(do_command(THD*, bool))[0x55f7ffd6e8c1]
??:0(do_handle_one_connection(CONNECT*, bool))[0x55f7ffe69b77]
??:0(handle_one_connection)[0x55f7ffe69edd]
??:0(MyCTX_nopad::finish(unsigned char*, unsigned int*))[0x55f8001b85e9]
??:0(start_thread)[0x7f99abc78ea7]
??:0(clone)[0x7f99ab865a2f]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f99780112b0): COMMIT

Connection ID (thread ID): 13
Status: NOT_KILLED

Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off

The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
information that should help you find out what is causing the crash.
Writing a core file...
Working directory at /bitnami/mariadb/data
Resource Limits:
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             32768                32768                processes 
Max open files            65536                65536                files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       1807                 1807                 signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        
Core pattern: core

That error suggests a corrupted fulltext index. Try running this to rebuild it:

ALTER TABLE fulltext_search ENGINE=InnoDB;

Or, if that doesn’t work, run this:

OPTIMIZE TABLE fulltext_search;

Yes! That fixed it.

Thank you for pointing me in the right direction.

Incidentally I found the same command available in phpMyAdmin under the Operations tab for the table. It’s called “Defragment table”. Optimization is obviously there too.

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.