Skip to content

Report broken for long_running_queries since Ecto 3.12.0 #458

@saveman71

Description

@saveman71

From my understanding, Ecto starting parsing :duration as %Duration structs in v3.12.0. We've seen a few errors that I attribute to the new type but I may be wrong.

Environment

  • Elixir version (elixir -v):
Erlang/OTP 27 [erts-15.1.1] [source] [64-bit] [smp:20:20] [ds:20:20:10] [async-threads:1] [jit:ns]

Elixir 1.17.3 (compiled with Erlang/OTP 27)
  • Phoenix version (mix deps): phoenix 1.7.14
  • Phoenix LiveView version (mix deps): phoenix_live_view 0.20.17
  • Phoenix Dashboard version (mix deps): phoenix_live_dashboard 0.8.5
  • Operating system: Linux
  • Browsers you attempted to reproduce this bug on (the more the merrier): N/A

Actual behavior

When accessing the dahsboard for long_running_queries, I get a 500. It works if they aren't any long queries.

How to repro : MyApp.Repo.query!("select pg_sleep(5 * 60);")

On prod the error is

UndefinedFunctionError

function Duration.compare/2 is undefined or private

On local, don't have exactly this one, I have Phoenix.HTML.Safe not implemented for %Duration{}.

[I] 12:15:01.986 Phoenix.Logger.phoenix_endpoint_stop/4:231 GA2mgGCyNXIdp_UABVZC Sent 500 in 71ms                                                                                                                                                                                         
[E] 12:15:02.006 nil.: #PID<0.18104.0> running Phoenix.Endpoint.SyncCodeReloadPlug (connection #PID<0.18103.0>, stream id 1) terminated                                                                                                                                                   
Server: app-local.digiforma.com:80 (http)                                                                                                                                                                                                                                                 
Request: GET /internal/dashboard/ecto_stats?nav=long_running_queries&repo=Digiforma.Repo                                                                                                                                                                                                  
** (exit) an exception was raised:                                                                                                                                                                                                                                                        
    ** (Protocol.UndefinedError) protocol Phoenix.HTML.Safe not implemented for %Duration{second: 3, microsecond: {283748, 6}} of type Duration (a struct). This protocol is implemented for the following type(s): Atom, BitString, Cldr.Unit, Date, DateTime, Decimal, Float, Integer, L
ist, Money, NaiveDateTime, Phoenix.LiveComponent.CID, Phoenix.LiveView.Component, Phoenix.LiveView.Comprehension, Phoenix.LiveView.JS, Phoenix.LiveView.Rendered, Time, Tuple, URI                                                                                                        
        (phoenix_html 4.1.1) lib/phoenix_html/safe.ex:1: Phoenix.HTML.Safe.impl_for!/1                                                                                                                                                                                                    
        (phoenix_html 4.1.1) lib/phoenix_html/safe.ex:15: Phoenix.HTML.Safe.to_iodata/1                                                                                                                                                                                                   
        (phoenix_live_dashboard 0.8.5) lib/phoenix/live_dashboard/pages/ecto_stats_page.ex:183: anonymous fn/4 in Phoenix.LiveDashboard.EctoStatsPage.render_repo_tab/1                                                                                                                   
        (phoenix_live_view 0.20.17) lib/phoenix_live_view/diff.ex:391: Phoenix.LiveView.Diff.traverse/7                                                                                                                                                                                   
        (phoenix_live_view 0.20.17) lib/phoenix_live_view/diff.ex:532: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7                                                                                                                                                         
        (elixir 1.17.3) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3                                                                                                                                                                                                             
        (phoenix_live_view 0.20.17) lib/phoenix_live_view/diff.ex:389: Phoenix.LiveView.Diff.traverse/7                                                                                                                                                                                   
        (phoenix_live_view 0.20.17) lib/phoenix_live_view/diff.ex:559: anonymous fn/3 in Phoenix.LiveView.Diff.traverse_comprehension/5                                                                                                                                                   
        (elixir 1.17.3) lib/enum.ex:1829: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3                                                                                                                                                                                                      
        (elixir 1.17.3) lib/enum.ex:1829: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3                                                                                                                                                                                                      
        (elixir 1.17.3) lib/enum.ex:1829: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3                                                                                                                                                                                                      
        (elixir 1.17.3) lib/enum.ex:1829: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3                                                                                                                                                                                                      
        (phoenix_live_view 0.20.17) lib/phoenix_live_view/diff.ex:470: Phoenix.LiveView.Diff.traverse/7                                                                                                                                                                                   
        (phoenix_live_view 0.20.17) lib/phoenix_live_view/diff.ex:559: anonymous fn/3 in Phoenix.LiveView.Diff.traverse_comprehension/5                                                                                                                                                   
        (elixir 1.17.3) lib/enum.ex:1829: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3                                                                                                                                                                                                      
        (elixir 1.17.3) lib/enum.ex:1829: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3                                                                                                                                                                                                      
        (elixir 1.17.3) lib/enum.ex:1829: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3                                                                                                                                                                                                      
        (phoenix_live_view 0.20.17) lib/phoenix_live_view/diff.ex:480: Phoenix.LiveView.Diff.traverse/7                                                                                                                                                                                   
        (phoenix_live_view 0.20.17) lib/phoenix_live_view/diff.ex:532: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7                                                                                                                                                         
        (elixir 1.17.3) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3                                                                                                                                                                                                             

image

Expected behavior

No 500 if there are long running queries

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions