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

version cleanup fails on old databases with many entries #11278

Closed
tehlers320 opened this issue Mar 16, 2018 · 2 comments · Fixed by #11329
Closed

version cleanup fails on old databases with many entries #11278

tehlers320 opened this issue Mar 16, 2018 · 2 comments · Fixed by #11329
Assignees
Milestone

Comments

@tehlers320
Copy link

tehlers320 commented Mar 16, 2018

What Grafana version are you using?

5.0.1

What datasource are you using?

Aurora5.6 on r4.larges

What OS are you running grafana on?

Amazon Linux

What did you do?

Upgraded

What was the expected result?

Version trim works

What happened instead?

t=2018-03-16T15:44:34+0000 lvl=eror msg="Failed to delete expired dashboard versions" logger=cleanup error="Error 1390: Prepared statement contains too many placeholders"

A couple of notes:
As a user of grafana for a long time we had a pre-existing system which was not turned off when the "versioning" was enabled. This system continually updated dashboards and our versions kept increasing. The version table is 30GB so this may be an extreme case but other users may also see this bug if they have implemented the same thing.

@DanCech
Copy link
Collaborator

DanCech commented Mar 16, 2018

It sounds like the version cleanup job needs a limit on how many old versions it'll try to delete in one hit

@bergquist
Copy link
Contributor

Yeap.

I suggest we change how dashboard_versions are deleted

I think the select statement could be made into a Group By only using the dashboard_version table.
https://github.com/grafana/grafana/blob/master/pkg/services/sqlstore/dashboard_version.go#L79

When it comes to deleting I think we should delete ranges instead of per id.
https://github.com/grafana/grafana/blob/master/pkg/services/sqlstore/dashboard_version.go#L93

  1. Select the last X versions for dashboards with too many versions
  2. Save the first dashboard_id from that result
  3. Delete all dashboard_versions below that ID with the same dashboard_id

Deleting ranges of rows is much more performant than deleting by id

@bergquist bergquist added this to the 5.1 milestone Mar 23, 2018
ryantxu added a commit to ryantxu/grafana that referenced this issue Mar 23, 2018
* grafana/master: (30 commits)
  changelog: adds note about closing grafana#11278
  docs: spelling
  docs: add intro paragraph to provisioning page
  Cleanup CircleCI V2 Conversion
  changelog: notes for grafana#1271 and grafana#2740
  graph: minor fixes to y-axes alignment feature
  added save icon to save buttons
  removed trash can icon from save buttons
  Return actual user ID in UserProfileDTO
  dashboard version cleanup: more tests and refactor
  minor refactor of dashboard version cleanup
  refactor: dashboard version cleanup
  limit number of rows deleted by dashboard version cleanup
  fix dashboard version cleanup on large datasets
  Allocated to a separate alignment block. Replaced the attribute of the second axis by the attribute of the axes.
  Fixed unit test.
  Changed the way this feature was activated. And changed tolltip.
  Added validation of input parameters.
  Resolved conflict
  Corrected work for graphs created before this feature.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants