[Integrity Checker] Re-running the IC fails for SQL Server database
Expected Behavior
Regardless of how many times the IC is run, it should run consistently.
Current Behavior
If the Integrity Checker is executed more than once, it fails indicating a temporary table needed by the IC already exists.
Possible Solution
Make sure that the actual temp tables are dropped whether the Integrity checker:
- Reports any errors (and then get all data stored on xxxx_ir tables) or no conflicts at all.
- Process is stopped by the user.
Or make the temp tables as global temporary tables
https://technet.microsoft.com/en-us/library/ms177399(v=sql.105).aspx
Known Workarounds
Wait for a few secs until the thread that triggered this process is idle/dead and re-run the integrity checker. This way, the local temp tables are going to be deleted from the DB.
Steps to Reproduce (for bugs)
- Set up 2 4.2.2 instances under SQL Server databases.
- Configure push publishing between these environments.
- Run the Integrity Checker. No issues are found.
- After the first run ends, Run again the Integrity Checker immediately. Exception is thrown:
[20/12/17 11:13:53:826 CST] ERROR rest.IntegrityResource: Error checking integrity
java.lang.Exception: Error running the Folders Integrity Check
at com.dotcms.integritycheckers.FolderIntegrityChecker.generateIntegrityResults(FolderIntegrityChecker.java:211) ~[dotcms_4.2.2_999999.jar:?]
at com.dotcms.integritycheckers.IntegrityUtil.completeCheckIntegrity(IntegrityUtil.java:597) ~[dotcms_4.2.2_999999.jar:?]
at com.dotcms.rest.IntegrityResource$2.run(IntegrityResource.java:440) [dotcms_4.2.2_999999.jar:?]
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: There is already an object named '#folders_temp_1d3c8f8f95724a8ca28697907f78f1c7' in the d
atabase.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217) ~[sqljdbc42.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1635) ~[sqljdbc42.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:865) ~[sqljdbc42.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:762) ~[sqljdbc42.jar:?]
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:6276) ~[sqljdbc42.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1793) ~[sqljdbc42.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:184) ~[sqljdbc42.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:159) ~[sqljdbc42.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:735) ~[sqljdbc42.jar:?]
at com.dotmarketing.common.db.DotConnect.executeStatement(DotConnect.java:226) ~[dotcms_4.2.2_999999.jar:?]
at com.dotcms.integritycheckers.FolderIntegrityChecker.generateIntegrityResults(FolderIntegrityChecker.java:127) ~[dotcms_4.2.2_999999.jar:?]
... 2 more
However, the UI indicates it's still running until an error message is displayed.
Context
Reported by customer: https://dotcms.zendesk.com/agent/tickets/94986
Your Environment
- dotCMS version used: 4.2.2
- Browser Name and version: Any Browser.
- Operating System and version: Any OS.
- Application Server and version: Any Application Version.
- Java Brand and version: Any supported Java version.
- Database and version: SQL Server databases only.
- Application module (if apply):
PR: https://github.com/dotCMS/core/pull/13318
@dsilvam @wezell this fix does fix the issue BUT I still think there are better ways to delete the tables
if exists ... drop ...
But maybe that is another ticket? thoughts?
Yeah another ticket would be fine @jtesser
Passed QA. Configured push publishing using release-4.3.0 branch in sender and receiver servers. Ran Integrity Checker for the first time. No issues were found. Ran again the Integrity Checker immediately. No Exception is thrown I pushed some assed successfully Tested on release-4.3.0 branch Win7 Pro SP1 / SQLServer 2012 / Chrome v54.0.2840.98 / Tomcat 8 / Java 8
Passed QA. Configured push publishing using master branch in sender and receiver servers. Ran Integrity Checker for the first time. No issues were found. Ran several times Integrity Checker. No Exception is thrown I pushed some assed successfully Tested on master branch Win7 Pro SP1 / SQLServer 2012 / Chrome v64 / Tomcat 8 / Java 8