Skip to content

Commit

Permalink
#16277 Adding pagination to batch delete to avoid deadlocks in MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
nollymar committed Apr 23, 2019
1 parent 47e4ded commit ff1000b
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -180,11 +180,15 @@ protected void deleteReindexEntry(final List<ReindexEntry> recordsToDelete) thro

final int batchSize = REINDEX_RECORDS_TO_FETCH / 5;
int from = 0;
while(from <= recordsToDelete.size()){
dotConnect.executeBatch("DELETE FROM dist_reindex_journal where id = ?",
while (from <= recordsToDelete.size()) {
dotConnect.executeBatch(
"DELETE FROM dist_reindex_journal where " + (DbConnectionFactory.isMySql()
? "id = ?" : "ident_to_index = ?"),
recordsToDelete
.subList(from, Math.min(recordsToDelete.size(), batchSize + from))
.stream().map(entry -> new Params(entry.getId())).collect(
.stream().map(entry -> new Params(
DbConnectionFactory.isMySql() ? entry.getId()
: entry.getIdentToIndex())).collect(
Collectors.toList()));

from += batchSize;
Expand Down

0 comments on commit ff1000b

Please sign in to comment.