{"record":{"id":"73ba38b51b12ed8c","repo":"NationalSecurityAgency/ghidra","slug":"error-during-vector-deletion","errorCode":null,"errorMessage":"Error during vector deletion","messagePattern":"Error during vector deletion","errorType":"exception","errorClass":"ElasticException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java","lineNumber":1862,"sourceCode":"\t * @throws ElasticException for communication problems with the server\n\t */\n\tprivate void deleteRawVectors(Iterator<IdHistogram> iter, int maxVectors)\n\t\t\tthrows ElasticException {\n\t\tStringBuilder buffer = new StringBuilder();\n\t\tdo {\n\t\t\tIdHistogram entry = iter.next();\n\t\t\tbuffer.append(\"{ \\\"delete\\\": { \\\"_index\\\": \\\"\")\n\t\t\t\t\t.append(repository)\n\t\t\t\t\t.append(\"_vector\\\", \");\n\t\t\tbuffer.append(\"\\\"_id\\\": \\\"\");\n\t\t\tBase64Lite.encodeLongBase64(buffer, entry.id);\n\t\t\tbuffer.append(\"\\\" } }\\n\");\n\t\t\tmaxVectors -= 1;\n\t\t}\n\t\twhile (iter.hasNext() && maxVectors > 0);\n\t\tJsonObject resp = connection.executeBulk(\"/_bulk\", buffer.toString());\n\t\tif (resp.get(\"errors\").getAsBoolean()) {\n\t\t\tthrow new ElasticException(\"Error during vector deletion\");\n\t\t}\n\t}\n\n\t/**\n\t * Delete function documents and exe document associated with an executable id\n\t * @param exeId is the executable's document id\n\t * @return the number of function documents deleted\n\t * @throws ElasticException for communication problems with the server\n\t */\n\tprivate int deleteExeDocuments(String exeId) throws ElasticException {\n\t\tStringBuilder buffer = new StringBuilder();\n\t\tbuffer.append(\"{ \\\"query\\\": {\");\n\t\tbuffer.append(\"  \\\"parent_id\\\": {\");\n\t\tbuffer.append(\"    \\\"type\\\": \\\"function\\\",\");\n\t\tbuffer.append(\"    \\\"id\\\": \\\"\").append(exeId).append(\"\\\" } } }\");\n\t\tJsonObject resp = connection.executeStatement(ElasticConnection.POST,\n\t\t\t\"executable/_delete_by_query\", buffer.toString());\n\t\tlong numDocs = resp.get(\"deleted\").getAsLong();","sourceCodeStart":1844,"sourceCodeEnd":1880,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java#L1844-L1880","documentation":"Thrown in deleteRawVectors when the bulk delete response has \"errors\": true, meaning one or more individual delete operations within the _bulk request failed. Unlike the decrement path, this method does not inspect individual item errors — it fails fast on the top-level errors flag.","triggerScenarios":"Called during executable deletion to remove vector documents whose meta reference counts reached zero. The repository_vector/_bulk delete request completes but Elasticsearch sets errors=true because at least one sub-operation (delete by _id) encountered a problem.","commonSituations":"Vector documents were already deleted by a concurrent operation (version not found); shard unavailable or recovering; read-only index block (index.blocks.read_only); disk pressure triggering flood-stage watermark; permissions issue on specific documents.","solutions":["Inspect the individual item errors in the bulk response to identify which vector ids failed and why — modify the code or query _bulk manually to see per-item error details.","Clear any read-only blocks: PUT repository_vector/_settings {\"index.blocks.read_only\": null}.","Free disk space if Elasticsearch triggered the flood-stage read-only watermark.","Retry the deletion after shard recovery completes; ensure no concurrent delete targets the same vectors."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    database.query(deleteQuery);\n} catch (ElasticException e) {\n    if (e.getMessage().equals(\"Error during vector deletion\")) {\n        // Inspect per-item errors; may be transient (already deleted) or persistent (read-only)\n        Msg.warn(this, \"Vector deletion had errors — checking if vectors already removed: \" + e.getMessage());\n        // Retry or verify remaining vectors\n    }\n    throw e;\n}","preventionTips":["Clear read-only blocks on the vector index before deletion operations.","Ensure no concurrent delete targets the same vectors.","Monitor disk space to prevent flood-stage watermark from blocking writes and deletes."],"tags":["elasticsearch","bsim","bulk","delete","vector","partial-failure"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}