Conversation
|
joerghoh
left a comment
There was a problem hiding this comment.
a lot of minor nits, which I think the code could benefit from, mostly when it comes to readability.
+1 for the rest
| + (isolation < Connection.TRANSACTION_READ_COMMITTED ? "lower" : "higher") + " than expected " | ||
| + RDBJDBCTools.isolationLevelToString(Connection.TRANSACTION_READ_COMMITTED) | ||
| + " - check datasource configuration"); | ||
| LOG.info("Detected transaction isolation level {} is {} than expected {} - check datasource configuration", isolationDiags, isolation < Connection.TRANSACTION_READ_COMMITTED ? "lower" : "higher", RDBJDBCTools.isolationLevelToString(Connection.TRANSACTION_READ_COMMITTED)); |
There was a problem hiding this comment.
mixing the the simple varag parameters with the ternary expression in a single line? I would split it up into multiple lines, so it's more readable.
| LOG.info("RDBBlobStore (" + getModuleVersion() + ") instantiated for database " + dbDesc + ", using driver: " | ||
| + driverDesc + ", connecting to: " + dbUrl + (diag.isEmpty() ? "" : (", properties: " + diag.toString())) | ||
| + ", transaction isolation level: " + isolationDiags + ", " + tableInfo); | ||
| LOG.info("RDBBlobStore ({}) instantiated for database {}, using driver: {}, connecting to: {}{}, transaction isolation level: {}, {}", getModuleVersion(), dbDesc, driverDesc, dbUrl, diag.isEmpty() ? "" : (", properties: " + diag), isolationDiags, tableInfo); |
| // the meta is YOUNGER than x | ||
| dataStatement.append(" and not exists(select * from " + this.tnMeta + " where " + this.tnMeta + ".ID = " | ||
| + this.tnData + ".ID and LASTMOD > ?)"); | ||
| dataStatement.append(" and not exists(select * from ").append(this.tnMeta).append(" where ").append(this.tnMeta).append(".ID = ").append(this.tnData).append(".ID and LASTMOD > ?)"); |
There was a problem hiding this comment.
ahhh, don't know. That StringBuilder makes it much harder to understand. Personally I would prefer a String.format() approach, but I would be fine, if you just add some newlines into this statement.
| long elapsed = System.currentTimeMillis() - ts; | ||
| if (elapsed >= 20) { | ||
| LOG.debug("Obtaining a new connection from " + this.ds + " took " + elapsed + "ms", new Exception("call stack")); | ||
| LOG.debug("Obtaining a new connection from {} took {}ms", this.ds, elapsed, new Exception("call stack")); |
There was a problem hiding this comment.
In case this code line is reached and the loglevel is not set to DEBUG, the exception is created (expensive!) but not used. I would guard this debug statement here, so the exception is only created when the log statement is actually printed.
| LOG.debug("Obtaining a new connection from {} took {}ms", this.ds, elapsed, new Exception("call stack")); | |
| if (LOG.isDebugEnabled()) { | |
| LOG.debug("Obtaining a new connection from {} took {}ms", this.ds, elapsed, new Exception("call stack")); | |
| } |
| } catch (SQLException ex) { | ||
| LOG.error("Connection class " + c.getClass() | ||
| + " erroneously throws SQLException on setReadOnly(false); not trying again"); | ||
| LOG.error("Connection class {} erroneously throws SQLException on setReadOnly(false); not trying again", c.getClass()); |
There was a problem hiding this comment.
would it make sense to log ex.getMessage() as well to give some more diagnostics?
| if (oldDoc == null) { | ||
| // document was there but is now gone | ||
| LOG.debug("failed to apply update because document is gone in the meantime: " + update.getId(), new Exception("call stack")); | ||
| LOG.debug("failed to apply update because document is gone in the meantime: {}", update.getId(), new Exception("call stack")); |
There was a problem hiding this comment.
we should guard this log statement also with a check if the DEBUG log is enabled, otherweise we create the exception object without using it.
| int[] batchResults = new int[0]; | ||
|
|
||
| PreparedStatement stmt = connection.prepareStatement("update " + tmd.getName() | ||
| String statement = "update " + tmd.getName() |
There was a problem hiding this comment.
that is very hard to read ... would a String.format(...) help here?
| if (maj < dbmax || (maj == dbmax && min < dbmin)) { | ||
| result.append( | ||
| "Unsupported " + dbname + " version: " + maj + "." + min + ", expected at least " + dbmax + "." + dbmin); | ||
| result.append("Unsupported ").append(dbname).append(" version: ").append(maj).append(".").append(min).append(", expected at least ").append(dbmax).append(".").append(dbmin); |
There was a problem hiding this comment.
| result.append("Unsupported ").append(dbname).append(" version: ").append(maj).append(".").append(min).append(", expected at least ").append(dbmax).append(".").append(dbmin); | |
| result.append("Unsupported ").append(dbname) | |
| .append(" version: ").append(maj).append(".").append(min) | |
| .append(", expected at least ").append(dbmax).append(".").append(dbmin); |
| } | ||
| result.append("Unsupported " + dbname + " driver version: " + md.getDriverName() + " " + maj + "." + min | ||
| + ", expected at least " + drmax + "." + drmin); | ||
| result.append("Unsupported ").append(dbname).append(" driver version: ").append(md.getDriverName()).append(" ").append(maj).append(".").append(min).append(", expected at least ").append(drmax).append(".").append(drmin); |
There was a problem hiding this comment.
| result.append("Unsupported ").append(dbname).append(" driver version: ").append(md.getDriverName()).append(" ").append(maj).append(".").append(min).append(", expected at least ").append(drmax).append(".").append(drmin); | |
| result.append("Unsupported ").append(dbname) | |
| .append(" driver version: ").append(md.getDriverName()) | |
| .append(" ").append(maj).append(".").append(min) | |
| .append(", expected at least ").append(drmax).append(".").append(drmin); |
| return String.format("Strategy for %s set to %s (via system property %s)", RDBMissingLastRevSeeker.class.getName(), | ||
| name, value); | ||
| }).get(); | ||
| .loggingTo(LOG).validateWith(value -> (value == 1 || value == 2)).formatSetMessage((name, value) -> String.format("Strategy for %s set to %s (via system property %s)", RDBMissingLastRevSeeker.class.getName(), |
There was a problem hiding this comment.
Hard to understand ... maybe some more newlines?


No description provided.