{"record":{"id":"c333aa9bb148ce9f","repo":"NationalSecurityAgency/ghidra","slug":"already-inserted-c333aa","errorCode":null,"errorMessage":"Already inserted","messagePattern":"Already inserted","errorType":"exception","errorClass":"DatabaseNonFatalException","httpStatus":null,"severity":"warning","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java","lineNumber":3064,"sourceCode":"\t\t\tinfo.settings = query.manage.getSettings();\n\t\t\twriteBasicInfo(0, 0); // Save off the settings associated with this first insert\n\t\t}\n\t\tResponseInsert response = query.insertresponse;\n\t\tif ((query.repo_override != null) && (query.repo_override.length() != 0)) {\n\t\t\tquery.manage.overrideRepository(query.repo_override, query.path_override);\n\t\t}\n\t\t// Insert each executable in turn\n\t\tboolean newExecutable = false;\n\t\tfor (ExecutableRecord erec : query.manage.getExecutableRecordSet()) {\n\t\t\tif (erec.isLibrary()) {\n\t\t\t\tinsertLibrary(query.manage, erec);\n\t\t\t}\n\t\t\telse if (insertExe(query.manage, erec)) {\n\t\t\t\tnewExecutable = true;\n\t\t\t}\n\t\t}\n\t\tif (!newExecutable) {\n\t\t\tthrow new DatabaseNonFatalException(\"Already inserted\");\n\t\t}\n\t\tresponse.numexe = query.manage.getExecutableRecordSet().size();\n\t\tresponse.numfunc = query.manage.numFunctions();\n\t}\n\n\t/**\n\t * Entry point for the Elasticsearch version of QueryPair command:\n\t *   Query for pairs functions in the database, and compute the similarity\n\t *   and significance of their feature vectors\n\t * @param query is command parameters\n\t * @throws ElasticException for communication problems with the server\n\t * @throws LSHException for problems adding records to the response\n\t */\n\tprivate void fdbQueryPair(QueryPair query) throws ElasticException, LSHException {\n\t\tResponsePair response = query.pairResponse;\n\n\t\tdouble aveSim = 0.0;\n\t\tdouble aveSimSquare = 0.0;","sourceCodeStart":3046,"sourceCodeEnd":3082,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java#L3046-L3082","documentation":"After inserting every executable in an InsertRequest, if newExecutable stayed false (no non-library executable was newly inserted -- each was already present / non-fatal) it throws DatabaseNonFatalException(\"Already inserted\"), signalling the whole insert was a no-op.","triggerScenarios":"Re-ingesting an executable set where every non-library executable already exists in the database.","commonSituations":"Re-running an ingest pipeline over unchanged artifacts; an idempotent CI ingest step.","solutions":["Treat as expected: catch DatabaseNonFatalException and continue.","Drop the executables first to force a real re-insert.","Track insert state to skip sets known to be already present."],"exampleFix":"// before\ntry { db.insert(req); }\ncatch (Exception e) { throw new RuntimeException(e); } // crashes on benign re-ingest\n// after\ntry { db.insert(req); }\ncatch (DatabaseNonFatalException e) { log.info(\"No new executables: {}\", e.getMessage()); }","handlingStrategy":"try-catch","validationCode":"// Skip the round-trip if every md5 is already present.\nboolean anyNew = req.manage.getExecutableRecordSet().stream()\n    .anyMatch(e -> !db.hasExecutableForMd5(e.getMd5()));\nif (!anyNew) { log.info(\"Already inserted; skipping\"); return; }","typeGuard":null,"tryCatchPattern":"try { db.insert(req); }\ncatch (DatabaseNonFatalException e) { /* entire batch already present */ }\ncatch (LSHException | ElasticException e) { throw e; }","preventionTips":["Make batch ingest idempotent at the batch boundary.","Cache ingested md5 sets to short-circuit no-op batches."],"tags":["bsim","ingestion","duplicate"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}