recordAlreadyExists is silently eaten with no warning to logs

Description

This code in BasicSqlService.java effectively means that SqlServiceUniqueViolationException will never be thrown (as the if (recordAlreadyExists) block is unreachable).

As nothing seems to actually catch SqlServiceUniqueViolationException, that block should just be removed.

1223 // if asked to fail quietly, just return false if we find this error.
1224 if (recordAlreadyExists || failQuiet) return false;
1225
1226 // perhaps due to a mysql deadlock?
1227 if (sqlServiceSql.isDeadLockError(e.getErrorCode()))
1228 {
1229 // just a little fuss
1230 LOG.warn("Sql.dbWrite(): deadlock: error code: " + e.getErrorCode() + " sql: " + sql + " binds: " + debugFields(fields) + " " + e.toString());
1231 throw new SqlServiceDeadlockException(e);
1232 }
1233
1234 else if (recordAlreadyExists)
1235 {
1236 // just a little fuss
1237 LOG.warn("Sql.dbWrite(): unique violation: error code: " + e.getErrorCode() + " sql: " + sql + " binds: " + debugFields(fields) + " " + e.toString());
1238 throw new SqlServiceUniqueViolationException(e);
1239 }

Attachments

1
  • 27 May 2014, 02:21 PM

Activity

Show:

Hudson CI Server May 29, 2014 at 10:22 PM

Integrated in sakai-10-java-1.7 #81 (See http://builds.sakaiproject.org:8080/job/sakai-10-java-1.7/81/)
https://sakaiproject.atlassian.net/browse/KNL-385#icft=KNL-385 merge 309831 to 10.x (Revision 309954)

Result = UNSTABLE

Hudson CI Server May 27, 2014 at 6:05 PM

Integrated in sakai-trunk-java-1.7 #274 (See http://builds.sakaiproject.org:8080/job/sakai-trunk-java-1.7/274/)
https://sakaiproject.atlassian.net/browse/KNL-385#icft=KNL-385 show a warning in the logs if the record already exists instead of silently swallowing the error (Revision 309831)

Result = UNSTABLE

Sam Ottenhoff May 27, 2014 at 3:14 PM

Trunk commit r309831

Aaron Zeckoski May 27, 2014 at 3:05 PM

Let's put in the simple patch for now. It's better than nothing IMO

Sam Ottenhoff May 15, 2014 at 1:13 PM
Edited

Attached is a simple patch to add a warn to the logs. Changing the logic will immediately break other places. Just printing these messages to the logs will hopefully help us catch issues like https://sakaiproject.atlassian.net/browse/KNL-1250#icft=KNL-1250 without having to hear from our DBAs.

Fixed

Details

Priority

Affects versions

Fix versions

Components

Assignee

Reporter

Created October 5, 2007 at 12:34 AM
Updated April 25, 2018 at 3:18 PM
Resolved May 27, 2014 at 3:14 PM

Flag notifications