-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Usage] workspace.go:68 Error 1390: Prepared statement contains too many placeholders #10642
Comments
As suggested on StackOverflow, a small 🛹 fix here could be to split the workspaces query (see quoted line of code ☝️) into chunks of e.g. 1000 IDs max, then run all the chunks one by one. Also, I'm a bit uneasy about the |
/cc @andrew-farries As you're working on the usage component at the moment. |
FYI, as a better, longer-term fix, we could refactor the current code (which has large queries & several iterations over the same data) to try and:
We could e.g. do something like this:
SELECT `id`, `workspaceId`, `creationTime`, `stoppedTime`, `workspaceClass`
FROM d_b_workspace_instance
WHERE stoppedTime >= '$BEGINNING_OF_PERIOD' AND creationTime < '$END_OF_PERIOD' AND startedTime != '' (Currently, we query all the fields from all the instances, even unnecessary fields and instances that never started: source)
SELECT ownerId, projectId
FROM d_b_workspace
WHERE id IN ('$UNIQUE_WS_IDS') and then further sum up usage durations per user / per project, and back-fill the ownership information into every relevant usage record.
An alternative approach could be to do all the joins in SQL directly, but from my understanding, this is typically less efficient, and prevents using caching or sharding on intermediate steps. |
Reopening as #10778 still needs to land to close this. |
Bug description
It looks like our
usage
component is logging an error containing tons of workspace IDs once every minute:I believe the problem arises here:
gitpod/components/usage/pkg/controller/reconciler.go
Line 204 in 39557c3
when we try to get all the workspaces corresponding to all the workspace instances which ran some time this month.
Reminder: Gitpod runs tons of workspaces and instances each month. We should be careful when querying them all into memory and/or dumping them all into logs. (And, currently, the usage component does both every minute.)
See also:
Steps to reproduce
usage
component logs in productionWorkspace affected
No response
Expected behavior
No response
Example repository
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: