Matomo crashes my mariadb database


Hi, we use Matomo since a long time (archives date back til 2006 :slight_smile: ), but today our mariadb database was crashed by Matomo :frowning_face:.

From the DB dump (see below) there is a very long/cryptic SQL query, which seems to have been generated by core/RankingQuery / generateRankingQuery(…).
I’m not sure, if I need to adjust some Mariadb config parameters, or if this is really a bug. Can anybody help?

Here is the relevant mysqld.log part:

190218 12:11:58 [ERROR] mysqld got signal 11 ;
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

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.0.35-MariaDB
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 371914 K bytes of memory
Hope that’s ok; if not, decrease some variables in the equation.

Thread pointer: 0x5618a621e218
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 = 0x7f52fb802ed8 thread_stack 0x48000

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

                                    WHEN counter = 50001 THEN '-1'
                                    ELSE `idaction`
                            END AS `idaction`
                                    WHEN counter = 50001 THEN '-1'
                                    ELSE `name`
                            END AS `name`

                            , `url_prefix`, min(`28`) AS `28`, sum(`29`) AS `29`, sum(`2`) AS `2`, `1`, sum(`12`) AS `12`, sum(`30`) AS `30`, sum(`31`) AS `31`, min(`32`) AS `32`, max(`33`) AS `33`, `type`
                    FROM (
                            `idaction`, `name`,

                            WHEN `type` = 1 AND @counter1 = 50001 THEN 50001
                            WHEN `type` = 1 THEN @counter1:=@counter1+1
                            WHEN `type` = 2 AND @counter2 = 50001 THEN 50001
                            WHEN `type` = 2 THEN @counter2:=@counter2+1
                            WHEN `type` = 3 AND @counter3 = 50001 THEN 50001
                            WHEN `type` = 3 THEN @counter3:=@counter3+1
                            WHEN `type` = 4 AND @counter4 = 50001 THEN 50001
                            WHEN `type` = 4 THEN @counter4:=@counter4+1
                            WHEN `type` = 8 AND @counter8 = 50001 THEN 50001
                            WHEN `type` = 8 THEN @counter8:=@counter8+1
                            ELSE 0
             AS counter
                            , `url_prefix`, `28`, `29`, `2`, `1`, `12`, `30`, `31`, `32`, `33`, `type`
                            ( SELECT @counter1:=0 ) initCounter1, ( SELECT @counter2:=0 ) initCounter2, ( SELECT @counter3:=0 ) initCounter3, ( SELECT @counter4:=0 ) initCounter4, ( SELECT @counter8:=0 ) initCounter8,
                            ( SELECT /* Actions */
            log_action.url_prefix, count(distinct log_link_visit_action.idvisit) as `2`, count(distinct log_link_visit_action.idvisitor) as `1`, count(*) as `12`, sum(
                    case when custom_float is null
                        then 0
                        else custom_float
            ) / 1000 as `30`, sum(
                case when custom_float is null
                    then 0
                    else 1
            ) as `31`, min(custom_float) / 1000 as `32`, max(custom_float) / 1000 as `33`,
            CASE WHEN (MAX(log_link_visit_action.custom_var_v5) = 0
                AND log_link_visit_action.custom_var_k5 = '_pk_scount')
            THEN 1 ELSE 0 END
                AS `28`,
            SUM( CASE WHEN log_action_name_ref.type = 8
                  THEN 1 ELSE 0 END)
                AS `29`
                            p_log_link_visit_action AS log_link_visit_action LEFT JOIN p_log_action AS log_action ON log_link_visit_action.idaction_name = log_action.idaction LEFT JOIN p_log_action AS log_action_name_ref ON log_link_visit_action.idaction_name_ref = log_action_name_ref.idaction
                            log_link_visit_action.server_time >= '2019-02-17 23:00:00'
                            AND log_link_visit_action.server_time <= '2019-02-18 22:59:59'
                            AND log_link_visit_action.idsite IN ('29') AND log_link_visit_action.idaction_name IS NOT NULL AND log_link_visit_action.idaction_event_category IS NULL
                    GROUP BY
                    ORDER BY
                            `12` DESC, name ASC ) actualQuery
             ) AS withCounter
                    GROUP BY counter, `type`

Connection ID (thread ID): 215723

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=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=off

The manual page at contains
information that should help you find out what is causing the crash.

(Lukas Winkler) #2


Honsetly I have not really an idea why this happens, so this is just a random guess, but Matomo should never be able to crash MariaDB no matter what happens.

I see that you are using 10.0.35, is there any reason for this? Is it still supported by your distribution?
Even debian jessie the oldstable version ships 10.0.38 which is newer.