{"record":{"id":"d7d8988999269015","repo":"NationalSecurityAgency/ghidra","slug":"unable-to-initialize-new-thresholds","errorCode":null,"errorMessage":"Unable to initialize new thresholds: ","messagePattern":"Unable to initialize new thresholds: ","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/TableScoreCaching.java","lineNumber":219,"sourceCode":"\t\tquery.tableName = TABLE_NAME;\n\t\tquery.keyType = Types.VARCHAR;\n\t\tquery.valueType = Types.REAL;\n\t\tquery.attemptCreation = false;\n\t\tquery.clearTable = true;\t\t\t\t\t\t\t\t// Clear out the table\n\t\tResponseOptionalExist response = query.execute(db);\n\t\tif (response == null) {\n\t\t\tthrow new LSHException(db.getLastError().message);\n\t\t}\n\t\tif (!response.tableExists) {\n\t\t\tthrow new LSHException(\"Optional table does not exist when it should: \" + TABLE_NAME);\n\t\t}\n\t\tsetUpInsert(2);\n\t\tinsertValue.keys[0] = SIMILARITY_KEY;\n\t\tinsertValue.keys[1] = SIGNIFICANCE_KEY;\n\t\tinsertValue.values[0] = Float.valueOf((float) simThreshold);\t\t// Write thresholds to special table rows\n\t\tinsertValue.values[1] = Float.valueOf((float) sigThreshold);\n\t\tif (insertValue.execute(db) == null) {\n\t\t\tthrow new LSHException(\"Unable to initialize new thresholds: \" + TABLE_NAME);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":201,"sourceCodeEnd":224,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/TableScoreCaching.java#L201-L224","documentation":"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().","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect db.getLastError() (or the underlying database error) immediately after this exception to find the root SQL failure.","Verify the database connection is alive and writable before setting thresholds.","Ensure the optional score table schema matches the current BSim client version (column types for keys/values).","Retry the operation after confirming no locks and sufficient disk space."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the connection is writable before setting thresholds.\nif (!db.isWritable()) {\n    throw new IllegalStateException(\"Database not writable; cannot set thresholds\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    scoreCaching.setThresholds(sim, sig);\n} catch (LSHException e) {\n    String last = db.getLastError() != null ? db.getLastError().message : \"unknown\";\n    throw new RuntimeException(\"Threshold init failed; DB error: \" + last, e);\n}","preventionTips":["Confirm the database connection is alive and writable before threshold writes.","Check disk space and locks on the database before bulk operations.","Inspect db.getLastError() immediately after a failed execute for the root SQL cause."],"tags":["bsim","database","write-failure","thresholds","lsh-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}