metabase / metabase

The simplest, fastest way to get business intelligence and analytics to everyone in your company :yum:
https://metabase.com
Other
38.77k stars 5.15k forks source link

Query requests gets duplicated and cancelled with Error in Static Embedding #41731

Open Tony-metabase opened 6 months ago

Tony-metabase commented 6 months ago

Describe the bug

When showing a dashboard in Static Embedding that has any filter linked to a question will be run twice. First run will get cancelled with broken pipe error and the second time it runs without issues.

The query and data still loads it's more of a logging kind of issue cause it generates redundant logs.

To Reproduce

  1. Go to New -> Question -> Sample Database -> Orders -> Count -> Save -> Add to Dashboard -> Link Date filter with Created At column
image
  1. Embed the dashboard and make the filter editable:
image
  1. Open Network Developer Tools and access the embedded URL ... You will see the cancelled request
image
  1. This can also be seen in the Query Log:
image

Note: Same thing happens on preview:

image

And it gets worse when there are a lot of cards since each card gets cancelled:

image

Expected behavior

Queries don't get cancelled and just run

Logs

[15cf1315-f7d6-4550-a784-46c53c0c78ed] 2024-04-23T14:45:57+02:00 ERROR metabase.query-processor.middleware.catch-exceptions Error processing query: Closed
{:database_id 4,
 :started_at #t "2024-04-23T12:45:50.045671Z[GMT]",
 :action_id nil,
 :json_query
 {:constraints {:max-results 10000, :max-results-bare-rows 2000},
  :type :query,
  :middleware {:js-int-to-string? true, :ignore-cached-results? false},
  :viz-settings {},
  :database 4,
  :query {:source-table 121, :aggregation [[:count]]},
  :parameters
  [{:type :date/all-options,
    :slug "date_filter",
    :id "3ef4a7f",
    :target [:dimension [:field 1076 {:base-type :type/DateTime}]]}],
  :async? true,
  :cache-ttl nil},
 :native {:query "SELECT COUNT(*) AS \"count\" FROM \"PUBLIC\".\"ORDERS\"", :params nil},
 :status :failed,
 :class org.eclipse.jetty.io.EofException,
 :stacktrace
 ["org.eclipse.jetty.server.HttpOutput.checkWritable(HttpOutput.java:750)"
  "org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:780)"
  "java.base/java.io.OutputStream.write(Unknown Source)"
  "java.base/java.util.zip.GZIPOutputStream.writeHeader(Unknown Source)"
  "java.base/java.util.zip.GZIPOutputStream.<init>(Unknown Source)"
  "java.base/java.util.zip.GZIPOutputStream.<init>(Unknown Source)"
  "--> async.streaming_response$output_stream_delay$fn__43773.invoke(streaming_response.clj:111)"
  "async.streaming_response$delay_output_stream$fn__43782.invoke(streaming_response.clj:128)"
  "async.streaming_response.proxy$java.io.OutputStream$ff19274a.write(Unknown Source)"
  "query_processor.streaming.json$fn$reify__52442.finish_BANG_(json.clj:115)"
  "query_processor.streaming$streaming_reducedf$fn__53218.invoke(streaming.clj:132)"
  "api.public$public_reducedf$fn__96428.invoke(public.clj:134)"
  "query_processor.context$reducedf.invokeStatic(context.clj:78)"
  "query_processor.context$reducedf.invoke(context.clj:73)"
  "query_processor.context.default$default_reducef.invokeStatic(default.clj:40)"
  "query_processor.context.default$default_reducef.invoke(default.clj:25)"
  "query_processor.context$reducef.invokeStatic(context.clj:70)"
  "query_processor.context$reducef.invoke(context.clj:63)"
  "query_processor.context.default$default_runf$respond_STAR___50541.invoke(default.clj:45)"
  "driver.sql_jdbc.execute$execute_reducible_query$fn__79417.invoke(execute.clj:709)"
  "driver.h2$fn__82400$fn__82402.invoke(h2.clj:535)"
  "driver.sql_jdbc.execute$do_with_resolved_connection.invokeStatic(execute.clj:334)"
  "driver.sql_jdbc.execute$do_with_resolved_connection.invoke(execute.clj:317)"
  "driver.h2$fn__82400.invokeStatic(h2.clj:526)"
  "driver.h2$fn__82400.invoke(h2.clj:522)"
  "driver.sql_jdbc.execute$execute_reducible_query.invokeStatic(execute.clj:692)"
  "driver.sql_jdbc.execute$execute_reducible_query.invoke(execute.clj:678)"
  "driver.sql_jdbc.execute$execute_reducible_query.invokeStatic(execute.clj:689)"
  "driver.sql_jdbc.execute$execute_reducible_query.invoke(execute.clj:678)"
  "driver.sql_jdbc$fn__112715.invokeStatic(sql_jdbc.clj:78)"
  "driver.sql_jdbc$fn__112715.invoke(sql_jdbc.clj:76)"
  "driver.h2$fn__82241.invokeStatic(h2.clj:272)"
  "driver.h2$fn__82241.invoke(h2.clj:268)"
  "query_processor.context$executef.invokeStatic(context.clj:60)"
  "query_processor.context$executef.invoke(context.clj:49)"
  "query_processor.context.default$default_runf.invokeStatic(default.clj:44)"
  "query_processor.context.default$default_runf.invoke(default.clj:42)"
  "query_processor.context$runf.invokeStatic(context.clj:46)"
  "query_processor.context$runf.invoke(context.clj:40)"
  "query_processor.reducible$identity_qp.invokeStatic(reducible.clj:39)"
  "query_processor.reducible$identity_qp.invoke(reducible.clj:36)"
  "query_processor.middleware.cache$maybe_return_cached_results$maybe_return_cached_results_STAR___72243.invoke(cache.clj:229)"
  "query_processor.middleware.permissions$check_query_permissions$fn__66600.invoke(permissions.clj:140)"
  "metabase_enterprise.advanced_permissions.query_processor.middleware.permissions$fn__107143$check_download_permissions__107144$fn__107145.invoke(permissions.clj:127)"
  "query_processor.middleware.enterprise$check_download_permissions_middleware$fn__72064.invoke(enterprise.clj:51)"
  "metabase_enterprise.sandbox.query_processor.middleware.column_level_perms_check$fn__107988$maybe_apply_column_level_perms_check__107989$fn__107990.invoke(column_level_perms_check.clj:33)"
  "query_processor.middleware.enterprise$maybe_apply_column_level_perms_check_middleware$fn__72074.invoke(enterprise.clj:64)"
  "query_processor.middleware.mbql_to_native$mbql__GT_native$fn__71506.invoke(mbql_to_native.clj:24)"
  "query_processor$fn__73411$combined_post_process__73416$combined_post_process_STAR___73417.invoke(query_processor.clj:262)"
  "query_processor$fn__73411$combined_pre_process__73412$combined_pre_process_STAR___73413.invoke(query_processor.clj:259)"
  "query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__66697.invoke(fetch_source_query.clj:303)"
  "query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__72154$fn__72158.invoke(resolve_database_and_driver.clj:77)"
  "driver$do_with_driver.invokeStatic(driver.clj:97)"
  "driver$do_with_driver.invoke(driver.clj:92)"
  "query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__72154.invoke(resolve_database_and_driver.clj:76)"
  "query_processor.middleware.store$initialize_store$fn__67324$fn__67325.invoke(store.clj:14)"
  "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:169)"
  "query_processor.store$do_with_metadata_provider.invoke(store.clj:150)"
  "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:158)"
  "query_processor.store$do_with_metadata_provider.invoke(store.clj:150)"
  "query_processor.middleware.store$initialize_store$fn__67324.invoke(store.clj:13)"
  "query_processor.middleware.resolve_database_and_driver$resolve_database$fn__72151.invoke(resolve_database_and_driver.clj:60)"
  "query_processor.middleware.normalize_query$normalize$fn__72456.invoke(normalize_query.clj:38)"
  "metabase_enterprise.audit_app.query_processor.middleware.handle_audit_queries$fn__79812$handle_audit_app_internal_queries__79813$fn__79815.invoke(handle_audit_queries.clj:142)"
  "query_processor.middleware.enterprise$handle_audit_app_internal_queries_middleware$fn__72102.invoke(enterprise.clj:103)"
  "query_processor.middleware.constraints$mark_needs_default_userland_constraints$fn__71217.invoke(constraints.clj:104)"
  "query_processor.middleware.process_userland_query$process_userland_query$fn__72387.invoke(process_userland_query.clj:156)"
  "query_processor.middleware.catch_exceptions$catch_exceptions$fn__72988.invoke(catch_exceptions.clj:171)"
  "query_processor.reducible$async_qp$qp_STAR___62838$thunk__62840.invoke(reducible.clj:126)"
  "query_processor.reducible$async_qp$qp_STAR___62838$fn__62842.invoke(reducible.clj:131)"],
 :card_id 132,
 :context :embedded-dashboard,
 :error "Closed",
 :row_count 0,
 :running_time 0,
 :preprocessed
 {:constraints {:max-results 10000, :max-results-bare-rows 2000},
  :type :query,
  :middleware {:js-int-to-string? true, :ignore-cached-results? false},
  :user-parameters
  [{:type :date/all-options,
    :slug "date_filter",
    :id "3ef4a7f",
    :target [:dimension [:field 1076 {:base-type :type/DateTime}]]}],
  :viz-settings {},
  :info {:executed-by 1, :context :embedded-dashboard, :card-id 132, :card-name "Orders, Count", :dashboard-id 31},
  :database 4,
  :query {:source-table 121, :aggregation [[:aggregation-options [:count] {:name "count"}]]},
  :async? true},
 :data {:rows [], :cols []}}

Information about your Metabase installation

1.49.6 note that it happens in Chrome but not on Safari

Severity

Minor since the query still runs but good to know why those get cancelled

Additional context

No response

paoliniluis commented 6 months ago

Probably related to https://github.com/metabase/metabase/issues/36775?

staal commented 6 months ago

As noted, it occurs running in Arc or Chrome (with and without extensions) but not Safari, so it could be something chromium specific.