mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #30768 from nextcloud/feat/chunked-mysql-joblist-remove
Do chuncked job deletion
This commit is contained in:
commit
d70e9d6516
2 changed files with 22 additions and 1 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue