{"record":{"id":"eb5cd4d7b9b335e6","repo":"NationalSecurityAgency/ghidra","slug":"could-not-rebuild-index","errorCode":null,"errorMessage":"Could not rebuild index: {}","messagePattern":"Could not rebuild index: (.+?)","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BulkSignatures.java","lineNumber":629,"sourceCode":"\t\t\tMsg.info(this, \"Successfully dropped index \" + dbDetail);\n\t\t}\n\t}\n\n\t/**\n\t * Rebuilds the current BSim database index.\n\t * \n\t * @throws IOException if there's an error establishing the database connection\n\t * @throws LSHException if there's an error issuing the query\n\t */\n\tpublic void rebuildIndex() throws IOException, LSHException {\n\t\tDatabaseInformation info = establishQueryServerConnection(false);\n\t\tAdjustVectorIndex query = new AdjustVectorIndex();\n\t\tquery.doRebuild = true;\n\t\tSystem.out.println(\"Starting rebuild ...\");\n\t\tResponseAdjustIndex response = query.execute(querydb);\n\t\tif (response == null) {\n\t\t\tBSimError lastError = querydb.getLastError();\n\t\t\tthrow new LSHException(\"Could not rebuild index: \" + lastError.message);\n\t\t}\n\t\tString dbDetail = \"for database \" + info.databasename + \" (\" + bsimServerInfo + \")\";\n\t\tif (!response.success) {\n\t\t\tString msg = \"Could not rebuild index \" + dbDetail;\n\t\t\tif (!response.operationSupported) {\n\t\t\t\tmsg += \": operation not supported\";\n\t\t\t}\n\t\t\tMsg.error(this, msg);\n\t\t}\n\t\telse {\n\t\t\tMsg.info(this, \"Successfully rebuilt index \" + dbDetail);\n\t\t}\n\t}\n\n\t/**\n\t * Performs a prewarm command on the BSim database.\n\t * \n\t * @throws IOException if there's an error establishing the database connection","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BulkSignatures.java#L611-L647","documentation":"Thrown in rebuildIndex when ResponseAdjustIndex response is null after issuing AdjustVectorIndex with doRebuild=true. The server could not perform the rebuild and BulkSignatures wraps its BSimError message as 'Could not rebuild index: <message>' (LSHException). A non-null response that indicates the operation is unsupported is logged, not thrown.","triggerScenarios":"Rebuilding the index on a near-empty database, a backend lacking rebuild support, a connection failure during the (potentially long) rebuild, or insufficient resources.","commonSituations":"Calling rebuildIndex before any signatures are ingested; backend resource exhaustion (memory/disk) during rebuild; unsupported backend; privileges.","solutions":["Ingest signatures first so the index has data to build over, then rebuild.","Check the message and server logs for resource/permission causes.","Free backend resources (RAM/disk) and retry.","Confirm the backend supports rebuild operations."],"exampleFix":"// before\nbsim.rebuildIndex();  // empty DB -> LSHException\n\n// after\n// ingest first, then rebuild\nbsim.sendSignaturesToServer(dir, null, monitor);\nbsim.rebuildIndex();","handlingStrategy":"try-catch","validationCode":"// ingest signatures before rebuilding so the index has data\nbsim.sendSignaturesToServer(dir, null, monitor);","typeGuard":null,"tryCatchPattern":"try {\n    bsim.rebuildIndex();\n} catch (LSHException e) {\n    // message: \"Could not rebuild index: <server>\"; ensure data + resources, then retry\n}","preventionTips":["Ingest signatures before rebuilding the index.","Free backend RAM/disk before a rebuild.","Confirm the backend supports rebuild operations."],"tags":["bsim","index","rebuild-index","lshexception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}