languagetool-org/languagetool · error · RuntimeException
Error storing matches for '${sentence.getTitle()}'
Error message
Error storing matches for '${sentence.getTitle()}' What it means
DatabaseHandler.handleResult wraps any unexpected exception occurring while persisting rule matches for a sentence into a RuntimeException identifying the sentence title. Only DocumentLimitReachedException and ErrorLimitReachedException are re-thrown untouched; everything else (SQL errors, constraint violations) is wrapped. It signals the write path to the database failed mid-processing.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/DatabaseHandler.java:139
insertSt.setString(11, sentence.getUrl());
insertSt.setString(12, sentence.getSource());
insertSt.addBatch();
if (++batchCount >= batchSize){
executeBatch();
batchCount = 0;
}
checkMaxErrors(++errorCount);
if (errorCount % 100 == 0) {
System.out.println("Storing error #" + errorCount + " for text:");
System.out.println(" " + sentence.getText());
}
}
checkMaxSentences(++sentenceCount);
} catch (DocumentLimitReachedException | ErrorLimitReachedException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Error storing matches for '" + sentence.getTitle() + "'", e);
}
}
private void executeBatch() throws SQLException {
boolean autoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
try {
insertSt.executeBatch();
if (autoCommit) {
conn.commit();
}
} finally {
conn.setAutoCommit(autoCommit);
}
}
@Override
public void close() throws Exception {View on GitHub (pinned to 2e990059ce)
Solutions
- Inspect the cause chain (getCause) for the underlying SQLException
- Verify DB connectivity and increase wait_timeout / reconnect settings for long runs
- Check schema constraints and column sizes against the sentence/match data
- Re-run from the failing document; enable smaller batch commits
Example fix
// before
throw new RuntimeException("Error storing matches for '" + sentence.getTitle() + "'", e);
// after
LOG.error("Error storing matches for '" + sentence.getTitle() + "'", e);
conn.rollback();
throw new RuntimeException("Error storing matches for '" + sentence.getTitle() + "'", e); Defensive patterns
Strategy: try-catch
Validate before calling
try (Connection c = DriverManager.getConnection(dbUrl, dbUser, dbPassword)) {
if (!c.isValid(5)) throw new IllegalStateException("DB connection invalid before run");
} Try / catch
try {
handler.handleResult(sentence, matches, language);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Error storing matches")) {
log.error("DB write failed for " + sentence.getTitle() + ": " + e.getCause(), e);
// skip sentence or retry with fresh connection
} else throw e;
} Prevention
- Increase MySQL wait_timeout and enable autoReconnect for long dumps
- Size text columns (TEXT/MEDIUMTEXT) for long sentences
- Commit in smaller batches
- Monitor connection health during bulk runs
When it happens
Trigger: executeBatch or the prepared-statement inserts throw a SQLException; the DB connection dropped; a sentence exceeds a column length; a commit fails during batching.
Common situations: MySQL server gone away on long dumps; duplicate-key/constraint errors in the matches table; column too small for long sentence text; connection pool timeout on large Wikipedia dumps.
Related errors
- DatabaseAccess.init() has not been called yet or failed
- dbLogging can only be true if dbDriver, dbUrl, dbUsername, a
- Required key '${key}' not found in properties
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/19d9628d4b2c4072.
Report an issue: GitHub.