NationalSecurityAgency/ghidra · error · LSHException

Unable to initialize new thresholds:

Error message

Unable to initialize new thresholds: 

What it means

Thrown by TableScoreCaching when the INSERT of the special similarity/significance threshold rows into the optional score table fails (insertValue.execute(db) returns null). This occurs right after confirming the table exists, during threshold persistence. A null return from execute indicates a database-level error captured in db.getLastError().

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/TableScoreCaching.java:219

		query.tableName = TABLE_NAME;
		query.keyType = Types.VARCHAR;
		query.valueType = Types.REAL;
		query.attemptCreation = false;
		query.clearTable = true;								// Clear out the table
		ResponseOptionalExist response = query.execute(db);
		if (response == null) {
			throw new LSHException(db.getLastError().message);
		}
		if (!response.tableExists) {
			throw new LSHException("Optional table does not exist when it should: " + TABLE_NAME);
		}
		setUpInsert(2);
		insertValue.keys[0] = SIMILARITY_KEY;
		insertValue.keys[1] = SIGNIFICANCE_KEY;
		insertValue.values[0] = Float.valueOf((float) simThreshold);		// Write thresholds to special table rows
		insertValue.values[1] = Float.valueOf((float) sigThreshold);
		if (insertValue.execute(db) == null) {
			throw new LSHException("Unable to initialize new thresholds: " + TABLE_NAME);
		}
	}

}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Inspect db.getLastError() (or the underlying database error) immediately after this exception to find the root SQL failure.
  2. Verify the database connection is alive and writable before setting thresholds.
  3. Ensure the optional score table schema matches the current BSim client version (column types for keys/values).
  4. Retry the operation after confirming no locks and sufficient disk space.
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the connection is writable before setting thresholds.
if (!db.isWritable()) {
    throw new IllegalStateException("Database not writable; cannot set thresholds");
}

Try / catch

try {
    scoreCaching.setThresholds(sim, sig);
} catch (LSHException e) {
    String last = db.getLastError() != null ? db.getLastError().message : "unknown";
    throw new RuntimeException("Threshold init failed; DB error: " + last, e);
}

Prevention

When it happens

Trigger: Calling setThresholds (which writes SIMILARITY_KEY and SIGNIFICANCE_KEY rows) on a TableScoreCaching backed by a database in a bad state — e.g., write-protected, connection dropped, constraint violation on the special key rows, or a schema mismatch on the value column type. setUpInsert(2) prepares a two-key insert; if the prepared statement is stale or the table structure changed, execute returns null.

Common situations: Database file is read-only or locked by another process. Network/HBase/PostgreSQL connection to the BSim backend dropped mid-operation. Schema drift where the optional table columns no longer match the insert statement. Disk full. Concurrent writers causing a deadlock that the driver surfaces as a null execute result.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/d7d8988999269015. Report an issue: GitHub.