From a7d8789ff4e7d9fbee4d9c277583c950069a8b2a Mon Sep 17 00:00:00 2001 From: Cristian Turlica Date: Wed, 21 Apr 2021 10:22:16 +0300 Subject: [PATCH] Revert "MNT-22186: propTablesCleanupJobDetail v2 can cause Out of Memory errors (CleanAlfPropTablesV2.sql ) (#390)" (#394) This reverts commit 5e38be6f7df6278c00f105baedf46daa3ec94318. --- .../script/DeleteNotExistsExecutor.java | 29 ++----------------- .../schema/script/ScriptExecutorImpl.java | 2 +- .../script/DeleteNotExistsExecutorTest.java | 8 ++--- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/repository/src/main/java/org/alfresco/repo/domain/schema/script/DeleteNotExistsExecutor.java b/repository/src/main/java/org/alfresco/repo/domain/schema/script/DeleteNotExistsExecutor.java index a5d4d54851..0437f36c0d 100644 --- a/repository/src/main/java/org/alfresco/repo/domain/schema/script/DeleteNotExistsExecutor.java +++ b/repository/src/main/java/org/alfresco/repo/domain/schema/script/DeleteNotExistsExecutor.java @@ -25,8 +25,6 @@ */ package org.alfresco.repo.domain.schema.script; -import org.alfresco.repo.domain.dialect.Dialect; -import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; import org.alfresco.util.LogUtil; import org.alfresco.util.Pair; import org.alfresco.util.PropertyCheck; @@ -76,7 +74,6 @@ public class DeleteNotExistsExecutor implements StatementExecutor private int line; private File scriptFile; private Properties globalProperties; - private Dialect dialect; private boolean readOnly; private int deleteBatchSize; @@ -87,18 +84,12 @@ public class DeleteNotExistsExecutor implements StatementExecutor private Date startTime; public DeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties) - { - this(connection, sql, line, scriptFile, globalProperties, null); - } - - public DeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties, Dialect dialect) { this.connection = connection; this.sql = sql; this.line = line; this.scriptFile = scriptFile; this.globalProperties = globalProperties; - this.dialect = dialect; } public void checkProperties() @@ -173,21 +164,6 @@ public class DeleteNotExistsExecutor implements StatementExecutor } } - /** - * @return Integer.MIN_VALUE in case of MySQL otherwise the batch size. - */ - private int computeFetchSize() - { - if (this.dialect instanceof MySQLInnoDBDialect) - { - // Note the MySQL specific fetch size limitation (Integer.MIN_VALUE). fetchSize - // activates result set streaming. - return Integer.MIN_VALUE; - } - - return batchSize; - } - private void process(Pair[] tableColumn, Long[] tableUpperLimits, String[] optionalWhereClauses) throws SQLException { // The approach is to fetch ordered row ids from all referencer/secondary (e.g. @@ -208,7 +184,6 @@ public class DeleteNotExistsExecutor implements StatementExecutor PreparedStatement[] secondaryPrepStmts = null; PreparedStatement deletePrepStmt = null; Set deleteIds = new HashSet<>(); - int fetchSize = computeFetchSize(); deletedCount = 0L; startTime = new Date(); @@ -216,7 +191,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor { connection.setAutoCommit(false); primaryPrepStmt = connection.prepareStatement(createPreparedSelectStatement(primaryTableName, primaryColumnName, primaryWhereClause)); - primaryPrepStmt.setFetchSize(fetchSize); + primaryPrepStmt.setFetchSize(batchSize); primaryPrepStmt.setLong(1, primaryId); primaryPrepStmt.setLong(2, tableUpperLimits[0]); @@ -229,7 +204,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor for (int i = 1; i < tableColumn.length; i++) { PreparedStatement secStmt = connection.prepareStatement(createPreparedSelectStatement(tableColumn[i].getFirst(), tableColumn[i].getSecond(), optionalWhereClauses[i])); - secStmt.setFetchSize(fetchSize); + secStmt.setFetchSize(batchSize); secStmt.setLong(1, primaryId); secStmt.setLong(2, tableUpperLimits[i]); diff --git a/repository/src/main/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImpl.java b/repository/src/main/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImpl.java index 22a586a67d..64f7c1a4ca 100644 --- a/repository/src/main/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImpl.java +++ b/repository/src/main/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImpl.java @@ -350,7 +350,7 @@ public class ScriptExecutorImpl implements ScriptExecutor } else if (sql.startsWith("--DELETE_NOT_EXISTS")) { - DeleteNotExistsExecutor deleteNotExists = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, globalProperties, dialect); + DeleteNotExistsExecutor deleteNotExists = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, globalProperties); deleteNotExists.execute(); // Reset diff --git a/repository/src/test/java/org/alfresco/repo/domain/schema/script/DeleteNotExistsExecutorTest.java b/repository/src/test/java/org/alfresco/repo/domain/schema/script/DeleteNotExistsExecutorTest.java index 6750a16f4e..cec74e14c0 100644 --- a/repository/src/test/java/org/alfresco/repo/domain/schema/script/DeleteNotExistsExecutorTest.java +++ b/repository/src/test/java/org/alfresco/repo/domain/schema/script/DeleteNotExistsExecutorTest.java @@ -90,7 +90,7 @@ public class DeleteNotExistsExecutorTest { when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_READ_ONLY)).thenReturn("true"); when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_TIMEOUT_SECONDS)).thenReturn("-1"); - DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, null); + DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties); deleteNotExistsExecutor.execute(); List res = jdbcTmpl.queryForList(select, String.class); @@ -100,7 +100,7 @@ public class DeleteNotExistsExecutorTest { when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_READ_ONLY)).thenReturn("false"); when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_TIMEOUT_SECONDS)).thenReturn("-1"); - DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, null); + DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties); deleteNotExistsExecutor.execute(); List res = jdbcTmpl.queryForList(select, String.class); @@ -133,7 +133,7 @@ public class DeleteNotExistsExecutorTest { when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_DELETE_BATCH_SIZE)).thenReturn("1"); when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_READ_ONLY)).thenReturn("false"); - DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, null); + DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties); deleteNotExistsExecutor.execute(); List res = jdbcTmpl.queryForList(select, String.class); @@ -167,7 +167,7 @@ public class DeleteNotExistsExecutorTest when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_BATCH_SIZE)).thenReturn("2"); when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_READ_ONLY)).thenReturn("false"); when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_TIMEOUT_SECONDS)).thenReturn("-1"); - DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, null); + DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties); deleteNotExistsExecutor.execute(); List res = jdbcTmpl.queryForList(select, String.class);