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

fix(db): pre- SELECT ids with a LIMIT to control the amount of rows deleted for MySQL #1309

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

miaulalala
Copy link
Collaborator

@miaulalala miaulalala commented Sep 11, 2023

Doctrine does not allow LIMITs on DELETE queries:

https://stackoverflow.com/questions/25308171/doctrine-query-delete-with-limit

Thus we need to handle MySQL/MariaDB separately as clustered setups are not going to be able to handle more than 128k rows / 2GB of writes at any one time.

I have set the current LIMIT to 10k but an argument could probably be made to use 20k. We can adjust in the future. I choose this limit to handle clustered setups where wsrep_max_ws_size or wsrep_max_ws_rows is lower than the expected value.

MySQL also doesn't allow LIMITs in IN subqueries.

@miaulalala

This comment was marked as resolved.

@miaulalala miaulalala changed the title fix(db): also chunk MariaDB deletes fix(db): pre- SELECT ids with a LIMIT to control the amount of rows deleted for MySQL Sep 11, 2023
Signed-off-by: Anna Larch <anna@nextcloud.com>
@miaulalala
Copy link
Collaborator Author

/backport to stable27

@miaulalala
Copy link
Collaborator Author

/backport to stable26

@miaulalala
Copy link
Collaborator Author

/backport to stable25

@miaulalala miaulalala merged commit e07dd96 into master Sep 13, 2023
34 checks passed
@miaulalala miaulalala deleted the fix/chunk-mariadb-also branch September 13, 2023 10:07
@backportbot-nextcloud

This comment was marked as resolved.

@backportbot-nextcloud

This comment was marked as resolved.

@backportbot-nextcloud

This comment was marked as resolved.

@nickvergessen
Copy link
Member

Doctrine does not allow LIMITs on DELETE queries:

Can we add a error (log) in the querybuilder when one tries that. I guess it's used in more places

@miaulalala
Copy link
Collaborator Author

Doctrine does not allow LIMITs on DELETE queries:

Can we add a error (log) in the querybuilder when one tries that. I guess it's used in more places

it will throw anyway from doctrine

@nickvergessen
Copy link
Member

it will throw anyway from doctrine

But the activity app never logged an error from it's cron job on our instance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants