Answers.Body: <p>The default innodb_buffer_pool_size is a very low 134217728. I bumped it up by adding</p>
  <pre><code>[mysqld]
  innodb_buffer_pool_size = 2G
  </code></pre>
  <p>to /etc/mysql/mariadb.conf.d/50-server.cnf</p>
  <p>The problem has not recurred. So this was a generic mariadb setup issue, not really related to Civicrm.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-08T03:14:20.230Z
Answers.LastActivityDate: 2023-01-08T03:14:20.230Z
Answers.UserDisplayName: twowheeler
Answers.Body: <p>Without addressing the MariaDB tuning directly:</p>
  <p>Consider having the MariaDB daemon <a href="https://ma.ttias.be/auto-restart-crashed-service-systemd/" rel="nofollow noreferrer">restart automatically</a>.</p>
  <p>I started seeing this problem after a Mosaico upgrade (2.8 maybe?).  You say it's happening during times of low traffic, but my guess is that it's when a mailing goes out?</p>
  <p>I haven't found a client who's affected enough to justify profiling this with XDebug, but you may want to try setting batch limits in the CiviMail settings to see if that alleviates your issue.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-03T21:22:14.887Z
Answers.Text: I wasn't aware of the auto restart ability, that sounds like a decent workaround. Thank you!
Answers.UserDisplayName: twowheeler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-03T21:27:00.897Z
Answers.Text: Re: "my guess is that it's when a mailing goes out?" I thought so too, and sometimes that is correct. But this morning it crashed at 5:00 AM with no civimail scheduled, and virtually no traffic. That's when I decided to post this question.
Answers.UserDisplayName: twowheeler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-03T21:43:24.493Z
Answers.Text: I will play with the Civimail settings. The only change I have made so far was to set the cron job limit to 1. That didn't help.
Answers.UserDisplayName: twowheeler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-03T19:01:06.600Z
Answers.LastActivityDate: 2023-01-03T19:01:06.600Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I'm trying to track down the cause of an occasional mariadb crash on my server. The system is a Linode 4GB Ubuntu 22.04 instance running Wordpress 6.1.1, apache2 2.4.52, mariadb 10.6.11, and civicrm 5.56.0.</p>
  <p>Generally it runs fine, but once in a while it returns a 500 database connection error. Mariadb is getting killed by oom-killer at the top of the hour, when the cronjobs kick off. Restarting mariadb returns it to normal function. This is happening more frequently, maybe once or twice a week.
  System memory does not seem to be an issue (this is when there is not much traffic on the site):</p>
  <pre><code> $ free -m
                  total        used        free      shared  buff/cache   available
   Mem:            3923         829        2088         128        1006        2712
   Swap:            511          53         458
  </code></pre>
  <p>The cronjobs look like:</p>
  <pre><code>*/5  * * * *    cd /var/www/html/; /usr/local/bin/wp --user=cronuser --url=https://thehcpac.org --path=/var/www/html/ cron event run --due-now &gt; /tmp/cron.log
  */10 * * * *    cd /var/www/html/; /usr/local/bin/wp --user=cronuser --url=https://thehcpac.org --path=/var/www/html/ --timezone=America/New_York civicrm api job.execute auth=0 &gt; /tmp/civicrm.log
  </code></pre>
  <p>Which seem pretty normal.</p>
  <p>So based on what I have read online, maybe the mariadb variables are not set correctly for this situation?</p>
  <pre><code>+-----------------+-----------+
  | Variable_name   | Value     |
  +-----------------+-----------+
  | key_buffer_size | 134217728 |
  +-----------------+-----------+
  | read_buffer_size | 131072 |
  +------------------+--------+
  | sort_buffer_size | 2097152 |
  +---------------------+----------+
  | max_heap_table_size | 16777216 |
  +---------------------+----------+
  | tmp_table_size | 16777216 |
  +----------------+----------+
  </code></pre>
  <p>I'm not any kind of database tuning expert, and am hoping for a pointer from someone who is. Thanks!</p>
  
Tags: <database><mysql><cron><cron-job><mariadb>
Title: Help with mariadb crash, out of memory error
ThreadText: # Help with mariadb crash, out of memory error
  
  (Asked by: username_0 on 2023-01-03)
  
  I'm trying to track down the cause of an occasional mariadb crash on my server. The system is a Linode 4GB Ubuntu 22.04 instance running Wordpress 6.1.1, apache2 2.4.52, mariadb 10.6.11, and civicrm 5.56.0.
  Generally it runs fine, but once in a while it returns a 500 database connection error. Mariadb is getting killed by oom-killer at the top of the hour, when the cronjobs kick off. Restarting mariadb returns it to normal function. This is happening more frequently, maybe once or twice a week.
  System memory does not seem to be an issue (this is when there is not much traffic on the site):
   $ free -m
                  total        used        free      shared  buff/cache   available
   Mem:            3923         829        2088         128        1006        2712
   Swap:            511          53         458
  
  The cronjobs look like:
  */5  * * * *    cd /var/www/html/; /usr/local/bin/wp --user=cronuser --url=https://thehcpac.org --path=/var/www/html/ cron event run --due-now > /tmp/cron.log
  */10 * * * *    cd /var/www/html/; /usr/local/bin/wp --user=cronuser --url=https://thehcpac.org --path=/var/www/html/ --timezone=America/New_York civicrm api job.execute auth=0 > /tmp/civicrm.log
  
  Which seem pretty normal.
  So based on what I have read online, maybe the mariadb variables are not set correctly for this situation?
  +-----------------+-----------+
  | Variable_name   | Value     |
  +-----------------+-----------+
  | key_buffer_size | 134217728 |
  +-----------------+-----------+
  | read_buffer_size | 131072 |
  +------------------+--------+
  | sort_buffer_size | 2097152 |
  +---------------------+----------+
  | max_heap_table_size | 16777216 |
  +---------------------+----------+
  | tmp_table_size | 16777216 |
  +----------------+----------+
  
  I'm not any kind of database tuning expert, and am hoping for a pointer from someone who is. Thanks!
  
  **Tags:** database, mysql, cron, cron-job, mariadb
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2023-01-08. Score: 1 | Accepted answer
  
  The default innodb_buffer_pool_size is a very low 134217728. I bumped it up by adding
  [mysqld]
  innodb_buffer_pool_size = 2G
  
  to /etc/mysql/mariadb.conf.d/50-server.cnf
  The problem has not recurred. So this was a generic mariadb setup issue, not really related to Civicrm.
  
  
  ---
  
  ### Answer by username_1 on 2023-01-03. Score: 0
  
  Without addressing the MariaDB tuning directly:
  
  Consider having the MariaDB daemon [restart automatically](https://ma.ttias.be/auto-restart-crashed-service-systemd/).
  
  I started seeing this problem after a Mosaico upgrade (2.8 maybe?). You say it's happening during times of low traffic, but my guess is that it's when a mailing goes out?
  
  I haven't found a client who's affected enough to justify profiling this with XDebug, but you may want to try setting batch limits in the CiviMail settings to see if that alleviates your issue.
  
  > **Comments:**
  > **username_0**: I wasn't aware of the auto restart ability, that sounds like a decent workaround. Thank you!  
  > **username_0**: Re: "my guess is that it's when a mailing goes out?" I thought so too, and sometimes that is correct. But this morning it crashed at 5:00 AM with no civimail scheduled, and virtually no traffic. That's when I decided to post this question.  
  > **username_0**: I will play with the Civimail settings. The only change I have made so far was to set the cron job limit to 1. That didn't help.  
  
  ---
  
  