{"record":{"id":"492321bf4f7d9fae","repo":"NationalSecurityAgency/ghidra","slug":"error-querying-vectorid","errorCode":null,"errorMessage":"Error querying vectorid: ","messagePattern":"Error querying vectorid: ","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java","lineNumber":1373,"sourceCode":"\t * @param simres receives the list of results and their similarity to the base vector\n\t * @return number of \n\t * @throws SQLException if there is an error issuing the query\n\t * @throws LSHException if executable record creation fails\n\t */\n\tprotected int retrieveFuncDescFromVectors(VectorResult dresult, DescriptionManager res,\n\t\t\tint count, QueryNearest query, BSimSqlClause filter, SimilarityResult simres)\n\t\t\tthrows SQLException, LSHException {\n\t\tSignatureRecord srec = res.newSignature(dresult.vec, dresult.hitcount);\n\t\tList<DescriptionRow> descres;\n\t\tif (filter == null) {\n\t\t\tdescres = descTable.queryVectorIdMatch(dresult.vectorid, query.max - count);\n\t\t}\n\t\telse {\n\t\t\tdescres = descTable.queryVectorIdMatchFilter(dresult.vectorid, filter.tableClause(),\n\t\t\t\tfilter.whereClause(), query.max - count);\n\t\t}\n\t\tif (descres == null) {\n\t\t\tthrow new SQLException(\"Error querying vectorid: \" + Long.toString(dresult.vectorid));\n\t\t}\n\t\tif (descres.size() == 0) {\n\t\t\tif (filter != null) {\n\t\t\t\treturn 0; // Filter may have eliminated all results\n\t\t\t}\n\t\t\t// Otherwise this is a sign of corruption in the database\n\t\t\tthrow new SQLException(\n\t\t\t\t\"No functions matching vectorid: \" + Long.toString(dresult.vectorid));\n\t\t}\n\t\tconvertDescriptionRows(simres, descres, dresult, res, srec);\n\t\treturn descres.size();\n\t}\n\n\t/**\n\t * \n\t * @param resultset the list of result set objects to populate\n\t * @param vec the vector containing the saveSQL query statement\n\t * @param simthresh the similarity threshold","sourceCodeStart":1355,"sourceCodeEnd":1391,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java#L1355-L1391","documentation":"In the single-result query path, after a nearest-neighbor vector is found, the code queries `descTable` for matching function rows. `queryVectorIdMatch` returns null on an internal query error (distinct from an empty result, which is handled separately). A null return means the underlying query itself failed, so SQLException is thrown carrying the vectorid.","triggerScenarios":"An internal failure during result resolution -- connection drop mid-query, transient DB error, or a null inside the query method. This is the single-result variant (line ~1373), separate from the bulk loop at 1847.","commonSituations":"Transient connection issues; DB under heavy load; partial state from a long-running query; driver timeout.","solutions":["Retry the query -- this is typically transient.","Check DB connectivity, pool health, and query latency.","If persistent, investigate the vectorid and descTable consistency."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Internal query error -- transient; retry with bounded backoff.\nSQLException last = null;\nfor (int attempt = 0; attempt < 3; attempt++) {\n    try { return db.queryNearest(query); }\n    catch (SQLException e) {\n        if (!e.getMessage().startsWith(\"Error querying vectorid:\")) throw e;\n        last = e;\n        Thread.sleep(100L * (1L << attempt));\n    }\n}\nthrow last;","preventionTips":["Keep the DB connection healthy and the pool sized for concurrency.","Monitor query latency and transient error rates.","Retry transient internal-query errors with backoff; escalate if persistent."],"tags":["database","query","vector","transient","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}