Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-03-18 14:29:42 +0300
committerGitHub <noreply@github.com>2022-03-18 14:29:42 +0300
commitd70e9d65167de800dfe7e8a9d3a2f6a83d2eb8a0 (patch)
treed01df7694707658b65558b59e9c7d8eab432968b
parent642f07ca3c18bc34f5d8c4b8894248e7eb2945ce (diff)
parentc870bd1968841f3141ec29e42f37f4608955bc88 (diff)
Merge pull request #30768 from nextcloud/feat/chunked-mysql-joblist-remove
Do chuncked job deletion
-rw-r--r--lib/private/BackgroundJob/JobList.php18
-rw-r--r--lib/public/DB/QueryBuilder/IQueryBuilder.php5
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php
index 67caea62af0..21af79c4686 100644
--- a/lib/private/BackgroundJob/JobList.php
+++ b/lib/private/BackgroundJob/JobList.php
@@ -29,6 +29,7 @@
*/
namespace OC\BackgroundJob;
+use Doctrine\DBAL\Platforms\MySQLPlatform;
use OCP\AppFramework\QueryException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\AutoloadNotAllowedException;
@@ -114,7 +115,22 @@ class JobList implements IJobList {
$argumentJson = json_encode($argument);
$query->andWhere($query->expr()->eq('argument_hash', $query->createNamedParameter(md5($argumentJson))));
}
- $query->execute();
+
+ // Add galera safe delete chunking if using mysql
+ // Stops us hitting wsrep_max_ws_rows when large row counts are deleted
+ if ($this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
+ // Then use chunked delete
+ $max = IQueryBuilder::MAX_ROW_DELETION;
+
+ $query->setMaxResults($max);
+
+ do {
+ $deleted = $query->execute();
+ } while ($deleted === $max);
+ } else {
+ // Dont use chunked delete - let the DB handle the large row count natively
+ $query->execute();
+ }
}
/**
diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php
index 669003246d9..76754f7bf41 100644
--- a/lib/public/DB/QueryBuilder/IQueryBuilder.php
+++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php
@@ -73,6 +73,11 @@ interface IQueryBuilder {
*/
public const PARAM_STR_ARRAY = Connection::PARAM_STR_ARRAY;
+ /**
+ * @since 24.0.0 Indicates how many rows can be deleted at once with MySQL
+ * database server.
+ */
+ public const MAX_ROW_DELETION = 100000;
/**
* Enable/disable automatic prefixing of table names with the oc_ prefix