Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to switch between databases after a question is created #38354

Closed
Tony-metabase opened this issue Feb 1, 2024 · 7 comments
Closed
Assignees
Labels
.Escalation Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Team/QueryingComponents Type:Bug Product defects
Milestone

Comments

@Tony-metabase
Copy link
Contributor

Tony-metabase commented Feb 1, 2024

Describe the bug

After you create a question you are not able to switch between databases

To Reproduce

Make sure you have 2 Databases Connected. In my case I have the App DB and Sample Database

  1. Go to New Question -> Sample DB -> Orders -> Save
  2. Go back to this question -> App DB (or any other DB apart form Sample DB) -> Core Users
image
  1. The question will break and if you do save this state and refresh you end up with the following, a data source pointing to a table in Sample Database which doesn't even exist there
image

Expected behavior

The GUI is able to identify changes in the Datasource

Logs

[57e0224d-423e-4700-bdb3-ec659484817e] 2024-02-01T10:57:27+01:00 ERROR metabase.query-processor.middleware.catch-exceptions Error processing query: Failed to fetch :metadata/table 65
{:database_id 1,
 :started_at #t "2024-02-01T09:57:27.002306Z[GMT]",
 :action_id nil,
 :error_type :invalid-query,
 :json_query
 {:database 1,
  :type "query",
  :query {:source-table 65, :limit 10},
  :parameters [],
  :middleware {:js-int-to-string? true, :add-default-userland-constraints? true}},
 :native nil,
 :status :failed,
 :class clojure.lang.ExceptionInfo,
 :stacktrace
 ["--> query_processor.store$missing_bulk_metadata_error.invokeStatic(store.clj:182)"
  "query_processor.store$missing_bulk_metadata_error.invoke(store.clj:181)"
  "query_processor.store$fn__49942$_AMPERSAND_f__49943$fn__49958.invoke(store.clj:221)"
  "query_processor.store$fn__49942$_AMPERSAND_f__49943.invoke(store.clj:219)"
  "query_processor.store$fn__49942$fn__49964.invoke(store.clj:189)"
  "query_processor.middleware.resolve_source_table$resolve_source_tables.invokeStatic(resolve_source_table.clj:39)"
  "query_processor.middleware.resolve_source_table$resolve_source_tables.invoke(resolve_source_table.clj:34)"
  "query_processor$preprocess_STAR_$fn__72762.invoke(query_processor.clj:163)"
  "query_processor$preprocess_STAR_.invokeStatic(query_processor.clj:161)"
  "query_processor$preprocess_STAR_.invoke(query_processor.clj:156)"
  "query_processor$fn__72770$combined_pre_process__72771$combined_pre_process_STAR___72772.invoke(query_processor.clj:258)"
  "query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__65702.invoke(fetch_source_query.clj:303)"
  "query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__71553$fn__71557.invoke(resolve_database_and_driver.clj:77)"
  "driver$do_with_driver.invokeStatic(driver.clj:94)"
  "driver$do_with_driver.invoke(driver.clj:89)"
  "query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__71553.invoke(resolve_database_and_driver.clj:76)"
  "query_processor.middleware.store$initialize_store$fn__66109$fn__66110.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__66109.invoke(store.clj:13)"
  "query_processor.middleware.resolve_database_and_driver$resolve_database$fn__71550.invoke(resolve_database_and_driver.clj:60)"
  "query_processor.middleware.normalize_query$normalize$fn__71855.invoke(normalize_query.clj:38)"
  "metabase_enterprise.audit_app.query_processor.middleware.handle_audit_queries$fn__79135$handle_audit_app_internal_queries__79136$fn__79138.invoke(handle_audit_queries.clj:142)"
  "query_processor.middleware.enterprise$handle_audit_app_internal_queries_middleware$fn__71501.invoke(enterprise.clj:103)"
  "query_processor.middleware.constraints$add_default_userland_constraints$fn__68599.invoke(constraints.clj:81)"
  "query_processor.middleware.process_userland_query$process_userland_query$fn__71786.invoke(process_userland_query.clj:156)"
  "query_processor.middleware.catch_exceptions$catch_exceptions$fn__72374.invoke(catch_exceptions.clj:171)"
  "query_processor.reducible$async_qp$qp_STAR___61150$thunk__61152.invoke(reducible.clj:126)"
  "query_processor.reducible$async_qp$qp_STAR___61150.invoke(reducible.clj:132)"
  "query_processor.reducible$sync_qp$qp_STAR___61162.doInvoke(reducible.clj:153)"
  "query_processor$process_userland_query.invokeStatic(query_processor.clj:401)"
  "query_processor$process_userland_query.doInvoke(query_processor.clj:397)"
  "query_processor$process_query_and_save_execution_BANG_.invokeStatic(query_processor.clj:415)"
  "query_processor$process_query_and_save_execution_BANG_.invoke(query_processor.clj:405)"
  "query_processor$process_query_and_save_with_max_results_constraints_BANG_.invokeStatic(query_processor.clj:430)"
  "query_processor$process_query_and_save_with_max_results_constraints_BANG_.invoke(query_processor.clj:420)"
  "api.dataset$run_query_async$fn__95443.invoke(dataset.clj:79)"
  "query_processor.streaming$streaming_response_STAR_$fn__51724$fn__51726.invoke(streaming.clj:168)"
  "query_processor.streaming$streaming_response_STAR_$fn__51724.invoke(streaming.clj:167)"
  "async.streaming_response$do_f_STAR_.invokeStatic(streaming_response.clj:69)"
  "async.streaming_response$do_f_STAR_.invoke(streaming_response.clj:67)"
  "async.streaming_response$do_f_async$task__43056.invoke(streaming_response.clj:88)"],
 :card_id nil,
 :context :ad-hoc,
 :error "Failed to fetch :metadata/table 65",
 :row_count 0,
 :running_time 0,
 :preprocessed nil,
 :ex-data
 {:status-code 400,
  :type :invalid-query,
  :metadata-provider
  (metabase.lib.metadata.cached-provider/cached-metadata-provider (metabase.lib.metadata.jvm/->UncachedApplicationDatabaseMetadataProvider 1)),
  :metadata-type :metadata/table,
  :id 65},
 :data {:rows [], :cols []}}

Information about your Metabase installation

Not able to replicate on master but able to hit it on 1.48.4 (and older 48 versions)

Severity

A customer is currently blocked in trying to replace Datasources

Additional context

I need to test but there is the possibility that if this action was already performed on the 47 and you upgraded to 48 things would still break

@Tony-metabase Tony-metabase added Type:Bug Product defects Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Needs Triage .Team/QueryProcessor :hammer_and_wrench: .Escalation labels Feb 1, 2024
@camsaul
Copy link
Member

camsaul commented Feb 2, 2024

I think this might be a frontend bug rather than a Cljs/MLv2 bug. What should be happening here is

  1. User changes the Database
  2. FE QB code should fetch relevant metadata as needed and discard the metadata for the old Database
  3. FE QB code should initialize a new MLv2 query with the new Database
  4. FE QB code should update state of the table picker so it's not still pointing to the old Database

I'm guessing some or all of these steps aren't happening correctly.

The error that comes back from the Query Processor is maybe not the most helpful error (we can fix this separately) but it's basically saying you're trying to run a query with a Table that either doesn't exist or belongs to a different Database. So that would point to the theory the the FE is not properly clearing things out and using Tables from the old DB in combination with the new one

@camsaul camsaul added .Team/QueryingComponents and removed .Team/QueryProcessor :hammer_and_wrench: labels Feb 2, 2024
@camsaul
Copy link
Member

camsaul commented Feb 2, 2024

I'm reassigning to the Query Components team since I'm like 90% sure this is a FE bug, if it turns out to be a backend/MLv2 bug after all please ping me. I'll open a separate backend issue to improve that error message.

@camsaul
Copy link
Member

camsaul commented Feb 2, 2024

Opened #38381 to track improving QP error message

@Tony-metabase
Copy link
Contributor Author

@camsaul Thanks for the detailed explanation! Sorry for tagging the wrong team

@kamilmielnik kamilmielnik self-assigned this Feb 2, 2024
@kamilmielnik kamilmielnik added this to the 0.48.5 milestone Feb 2, 2024
@kamilmielnik
Copy link
Contributor

Cannot reproduce in 0.47.0, 0.47.13.
Can reproduce in 0.48.0, 0.48.4.
Cannot reproduce on master.

@kamilmielnik
Copy link
Contributor

In master fixed by #37302

kamilmielnik added a commit that referenced this issue Feb 2, 2024
kamilmielnik added a commit that referenced this issue Feb 2, 2024
kamilmielnik added a commit that referenced this issue Feb 2, 2024
…is created (#38387)

* Add e2e test for #38354

* Rename file to match issue id

* Tag the test as external since it uses QA DBs

* Fix ORDERS_ID
kamilmielnik added a commit that referenced this issue Feb 2, 2024
#38386)

* Handle changing database in DataStep

* Add e2e test for #38354

* Add external tag, fix ORDERS_ID
This was referenced Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Escalation Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Team/QueryingComponents Type:Bug Product defects
Projects
None yet
Development

No branches or pull requests

5 participants