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

We're sending twice the necessary number of requests on x-ray first load #36775

Closed
paoliniluis opened this issue Dec 13, 2023 · 6 comments · Fixed by #40844
Closed

We're sending twice the necessary number of requests on x-ray first load #36775

paoliniluis opened this issue Dec 13, 2023 · 6 comments · Fixed by #40844
Assignees
Labels
Priority:P2 Average run of the mill bug Querying/X-rays .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. .Team/DashViz Dashboard and Viz team Type:Bug Product defects
Milestone

Comments

@paoliniluis
Copy link
Contributor

paoliniluis commented Dec 13, 2023

Describe the bug

UPDATE: getting the issue on a release version. The x-rays send lots of calls, that get rejected and then it sends again queries that get answered

To Reproduce

  1. set up 48.3 with a database
  2. add a db
  3. use any x-ray

Expected behavior

This should work normally, only the needed api calls

Logs

2023-12-13 21:43:12,749 DEBUG middleware.log :: GET /api/collection/tree 200 4.6 ms (5 DB calls) App DB connections: 0/15 Jetty threads: 8/50 (10 idle, 0 queued) (136 total active threads) Queries in flight: 0 (0 queued)
2023-12-13 21:43:12,753 DEBUG middleware.log :: GET /api/search 200 10.2 ms (4 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (10 idle, 0 queued) (136 total active threads) Queries in flight: 0 (0 queued)
2023-12-13 21:46:14,797 DEBUG middleware.log :: GET /api/database/2/schema/public 200 4.6 ms (4 DB calls) App DB connections: 0/15 Jetty threads: 7/50 (11 idle, 0 queued) (132 total active threads) Queries in flight: 0 (0 queued)
2023-12-13 21:46:17,964 DEBUG middleware.log :: GET /api/automagic-dashboards/table/62 200 35.9 ms (31 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (11 idle, 0 queued) (133 total active threads) Queries in flight: 0 (0 queued)
2023-12-13 21:46:17,982 DEBUG middleware.log :: GET /api/table/62/query_metadata 200 8.2 ms (9 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (11 idle, 0 queued) (133 total active threads) Queries in flight: 0 (0 queued)
2023-12-13 21:46:18,679 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 675.3 ms (15 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (9 idle, 0 queued) (133 total active threads) Queries in flight: 11 (0 queued); redshift DB 2 connections: 0/1 (0 threads blocked)
2023-12-13 21:46:19,821 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: canceled] 1.8 s (15 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 10 (0 queued); redshift DB 2 connections: 1/1 (0 threads blocked)
2023-12-13 21:46:19,859 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 1.6 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 9 (0 queued); redshift DB 2 connections: 1/1 (10 threads blocked)
2023-12-13 21:46:19,865 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: canceled] 1.9 s (15 DB calls) App DB connections: 1/15 Jetty threads: 7/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 8 (0 queued); redshift DB 2 connections: 1/1 (1 threads blocked)
2023-12-13 21:46:20,851 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 2.5 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 8 (0 queued); redshift DB 2 connections: 1/1 (6 threads blocked)
2023-12-13 21:46:20,876 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 1.0 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 8 (0 queued); redshift DB 2 connections: 4/4 (8 threads blocked)
2023-12-13 21:46:20,877 WARN middleware.log :: OST /api/dataset 404 94.0 µs (0 DB calls) 
#metabase.util.i18n.UserLocalizedString{:format-string "API endpoint does not exist.", :args [], :pluralization-opts {}}

2023-12-13 21:46:20,972 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 2.7 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 8 (0 queued); redshift DB 2 connections: 1/1 (9 threads blocked)
2023-12-13 21:46:21,754 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: canceled] 3.7 s (15 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 8 (0 queued); redshift DB 2 connections: 1/1 (2 threads blocked)
2023-12-13 21:46:21,841 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: canceled] 3.8 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 6 (0 queued); redshift DB 2 connections: 1/1 (3 threads blocked)
2023-12-13 21:46:21,841 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 3.5 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 6 (0 queued); redshift DB 2 connections: 1/1 (6 threads blocked)
2023-12-13 21:46:21,928 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 3.6 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 6 (0 queued); redshift DB 2 connections: 1/1 (6 threads blocked)
2023-12-13 21:46:21,998 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 1.0 s (16 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 6 (0 queued); redshift DB 2 connections: 7/7 (8 threads blocked)
2023-12-13 21:46:21,999 WARN middleware.log :: OST /api/dataset 404 101.7 µs (0 DB calls) 
#metabase.util.i18n.UserLocalizedString{:format-string "API endpoint does not exist.", :args [], :pluralization-opts {}}

2023-12-13 21:46:22,714 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 4.4 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 6 (0 queued); redshift DB 2 connections: 1/1 (5 threads blocked)
2023-12-13 21:46:22,730 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 728.7 ms (16 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 5 (0 queued); redshift DB 2 connections: 10/10 (4 threads blocked)
2023-12-13 21:46:22,867 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 1.0 s (16 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 4 (0 queued); redshift DB 2 connections: 10/10 (2 threads blocked)
2023-12-13 21:46:22,916 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: canceled] 4.9 s (15 DB calls) App DB connections: 0/15 Jetty threads: 6/50 (8 idle, 0 queued) (138 total active threads) Queries in flight: 3 (0 queued); redshift DB 2 connections: 1/1 (4 threads blocked)
2023-12-13 21:46:22,978 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 1.0 s (16 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 2 (0 queued); redshift DB 2 connections: 10/10 (3 threads blocked)
2023-12-13 21:46:28,818 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 7.9 s (16 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 1 (0 queued); redshift DB 2 connections: 7/7 (7 threads blocked)
2023-12-13 21:46:28,985 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 8.1 s (15 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (9 idle, 0 queued) (138 total active threads) Queries in flight: 0 (0 queued); redshift DB 2 connections: 7/7 (6 threads blocked)

Information about your Metabase installation

48.3

Severity

P3

Additional context

image

@paoliniluis paoliniluis added Type:Bug Product defects .Needs Triage Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Querying/X-rays and removed .Needs Triage labels Dec 13, 2023
@paoliniluis paoliniluis changed the title We seem to be sending more API calls than the ones we need on x-rays We seem to be sending more API calls than the ones we need on x-rays (v47.x with redshift v23 driver) Dec 13, 2023
@paoliniluis paoliniluis changed the title We seem to be sending more API calls than the ones we need on x-rays (v47.x with redshift v23 driver) We seem to be sending more API calls than the ones we need on x-rays (v47.x with redshift v23 driver // v48 as well) Dec 13, 2023
@paoliniluis paoliniluis added the .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. label Dec 13, 2023
@paoliniluis
Copy link
Contributor Author

getting this on 48.3 on postgres with a completely normal deployment
image

@paoliniluis paoliniluis changed the title We seem to be sending more API calls than the ones we need on x-rays (v47.x with redshift v23 driver // v48 as well) We seem to be sending more API calls than the ones we need on x-rays Jan 29, 2024
@paoliniluis paoliniluis added Priority:P3 Cosmetic bugs, minor bugs with a clear workaround and removed Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness labels Jan 29, 2024
@darksciencebase darksciencebase added the .Team/BackendComponents also known as BEC label Jan 30, 2024
@darksciencebase
Copy link
Contributor

@paoliniluis you've added the regression label — any hint on which version did this work normally on?

@paoliniluis
Copy link
Contributor Author

worked fine in 47.13, Jetty dependency upgrade maybe?

@paoliniluis paoliniluis added Priority:P2 Average run of the mill bug and removed Priority:P3 Cosmetic bugs, minor bugs with a clear workaround labels Mar 5, 2024
@piranha
Copy link
Contributor

piranha commented Mar 22, 2024

Bisect indicates that the first faulty commit is d161a9c, which is puzzling to me - there are almost no back-end changes.

@piranha
Copy link
Contributor

piranha commented Mar 29, 2024

I'm not sure if that commit is the problem, maybe I need to dig deeper. Why this commit appeared in bisect: it stopped removing null-values from parameterValues map. And DashboardData component would initiate request first with an empty map and then with map like {param1id: null, param2id: null}. So on the first look this change fixes the problem:

diff --git frontend/src/metabase/parameters/utils/parameter-values.ts frontend/src/metabase/parameters/utils/parameter-values.ts
index 06a18b1b26..beffe9ff33 100644
--- frontend/src/metabase/parameters/utils/parameter-values.ts
+++ frontend/src/metabase/parameters/utils/parameter-values.ts
@@ -105,6 +105,6 @@ export function getParameterValuesByIdFromQueryParams(
     parameters.map(parameter => [
       parameter.id,
       getParameterValueFromQueryParams(parameter, queryParams),
-    ]),
+    ]).filter(([_, v]) => v !== null),
   );
 }

But it turns out that if you select any parameter, then DashboardData first fetches data with empty map, and then with {param1id: "actualValue"} and double-requests are still happening! So it seems like d161a9c only surfaced the issue, but the issue itself happened somewhere earlier.

@piranha
Copy link
Contributor

piranha commented Apr 1, 2024

Okaaay! So the thing is, I've tested 47.13, and if you choose at least one of parameters, then you'll get that problem with sending and cancelling requests immediately. So obviously d161a9c just exposed that issue for the empty parameters, but it's there for a long time.

I think this is an escalation for some front-end dev to handle.

@piranha piranha removed their assignment Apr 1, 2024
@piranha piranha changed the title We seem to be sending more API calls than the ones we need on x-rays We're sending twice the necessary number of requests on x-ray first load Apr 1, 2024
@kulyk kulyk self-assigned this Apr 1, 2024
@kulyk kulyk added .Team/DashViz Dashboard and Viz team and removed .Team/BackendComponents also known as BEC labels Apr 1, 2024
@kulyk kulyk added this to the 0.49.3 milestone Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:P2 Average run of the mill bug Querying/X-rays .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. .Team/DashViz Dashboard and Viz team Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants