Skip to content

Issue with 1.2.0/1.2.1 on MariaDB #33

Closed

Description

@andyjeffries

I get this error ActiveRecord::StatementInvalid on SolidQueueMonitor::OverviewController#index:

Trilogy::QueryError: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server     
version for the right syntax to use near 'EPOCH FROM created_at) - 1774538672) / 3600 AS INTEGER) AS bucket_idx, COUNT(...'   
at line 1 (trilogy_query_recv)                                                                                                

��
According to Claude (it’s really late where I am and I’m jet lagged already):

This is a known compatibility issue — the EXTRACT(EPOCH FROM ...) syntax is PostgreSQL-specific and doesn't work on MariaDB.
   Let me find the exact source so we can monkey-patch it.
   1   # frozen_string_literal: true                                                     │ adapter?                          
   1   ����������������������������������������������������������������������������������│                                    
   2   # Monkey-patch SolidQueueMonitor::ChartDataService to recognize the Trilogy�������│                                    
   3   # adapter (MariaDB/MySQL) so it uses UNIX_TIMESTAMP instead of the PostgreSQL�����│                                    
   4   # EXTRACT(EPOCH FROM ...) syntax.�������������������������������������������������│                                    
   5   #���������������������������������������������������������������������������������│                                    
   6   # Upstream issue: the gem checks adapter?('mysql') but Trilogy reports its��������│                                    
   7   # adapter_name as "Trilogy", not "MySQL2".����������������������������������������│                                    
   8   ����������������������������������������������������������������������������������│                                    
   9   Rails.application.config.to_prepare do��������������������������������������������│                                    
  10   │ SolidQueueMonitor::ChartDataService.prepend(Module.new do�����������������������│                                    
  11   │ │ private�����������������������������������������������������������������������│                                    
  12   │ │�������������������������������������������������������������������������������│                                    
  13   │ │ def adapter?(name)������������������������������������������������������������│                                    
  14   │ │ │ adapter_name = ActiveRecord::Base.connection.adapter_name.downcase����������│                                    
  15   │ │ │ adapter_name.include?(name) || (name == "mysql" && adapter_name.include?    │                                    
       │ │ │ ("trilogy"))����������������������������������������������������������������│                                    
  16   │ │ end���������������������������������������������������������������������������│                                    
  17   │ end)����������������������������������������������������������������������������│                                    
  18   end

Anyway, it’s late, I’m copy/pasting on an iPad, so I hope this helps in a little way

Activity

  1. phmunhoz commented on Mar 27, 2026

    @phmunhoz
    Contributor

    Hi @andyjeffries,

    Can you try to point to the main branch of the project into you Gemfile and check if it works?

    I've made a PR to fix it and @vishaltps merged it into the main but it's not available in a version yet.

  2. vishaltps commented on Mar 28, 2026

    @vishaltps
    Owner

    @phmunhoz Does your fix for MySql will also work for MariaDB? I have never heard of it.

  3. andyjeffries commented on Mar 28, 2026

    @andyjeffries
    Author
  4. phmunhoz commented on Mar 28, 2026

    @phmunhoz
    Contributor

    @vishaltps — MariaDB is essentially a community-driven fork of MySQL, fully compatible in syntax and behavior.

    I've opened a pull request #34 with a proper fix. I tested it on a real project by switching between the mysql2 and trilogy adapters, and both work correctly now

  5. vishaltps commented on Mar 30, 2026

    @vishaltps
    Owner

    This has been fixed in v1.2.2 (release).

    The gem now natively recognizes the Trilogy adapter and uses UNIX_TIMESTAMP instead of the PostgreSQL-specific EXTRACT(EPOCH FROM ...) syntax, so the monkey-patch is no longer needed.

    To upgrade:

    gem 'solid_queue_monitor', '~> 1.2.2'

    Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions