jd-opensource/joyagent-jdgenie · error · RuntimeException
批量保存向量数据失败
Error message
批量保存向量数据失败
What it means
In syncVectorInfo, schema vectors are saved in batches via vectorService.saveVector(req); any exception in a batch is logged and rethrown as a plain RuntimeException '批量保存向量数据失败' (failed to batch-save vector data), aborting the whole synchronization and losing the error's original type/stack in the rethrown exception.
Solutions
- Check the log line 批量保存向量数据失败 for the original cause (e.getMessage() is logged with stack trace) and fix the underlying vector service issue
- Verify the vector store is reachable and the SCHEMA_COLLECTION_NAME collection exists with the expected dimension
- Reduce the batch size if timeouts or payload limits are involved
- Rethrow preserving the cause (new RuntimeException(msg, e)) so the real failure isn't hidden
Example fix
// before
} catch (Exception e) {
log.error("批量保存向量数据失败{}", e.getMessage(), e);
throw new RuntimeException("批量保存向量数据失败");
}
// after
} catch (Exception e) {
log.error("批量保存向量数据失败{}", e.getMessage(), e);
throw new RuntimeException("批量保存向量数据失败: " + e.getMessage(), e);
} Defensive patterns
Strategy: retry
Validate before calling
// pre-check before syncVectorInfo
if (!vectorService.collectionExists(DataAgentConstants.SCHEMA_COLLECTION_NAME)) {
vectorService.createCollection(DataAgentConstants.SCHEMA_COLLECTION_NAME, expectedDimension);
}
if (batch == null || batch.isEmpty()) {
throw new IllegalStateException("No vector data to save");
} Try / catch
try {
long total = chatModelInfoService.syncVectorInfo(...);
} catch (RuntimeException e) {
if ("批量保存向量数据失败".equals(e.getMessage())) {
log.error("Vector sync failed; check vector store availability and collection dimension", e);
// retry with smaller batch or back off
}
} Prevention
- Ensure the vector collection exists with the correct embedding dimension before syncing
- Check vector store connectivity/health before starting a sync
- Use smaller batches and add retry with backoff on saveVector failures
- Always preserve the original cause when rethrowing (new RuntimeException(msg, e))
When it happens
Trigger: vectorService.saveVector throwing for a batch — vector store unavailable/refusing connection, collection DataAgentConstants.SCHEMA_COLLECTION_NAME missing or dimension mismatch between embeddings and collection schema, embedding service failure producing bad vectors, or an oversized batch hitting payload limits.
Common situations: Vector database (e.g. Milvus/ES) is down or misconfigured in the environment; collection was recreated with a different embedding dimension; network timeouts on large batches; first-time sync where the collection hasn't been created yet.
Related errors
AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08).
Data as JSON: /api/errors/ab75b6f0c926ed05.
Report an issue: GitHub.
Appendix: source
Thrown at genie-backend/src/main/java/com/jd/genie/service/ChatModelInfoService.java:167
}
private int syncVectorInfo(List<ChatModelSchema> chatModelSchemas) {
List<VectorSaveReq.VectorData> vectorDataList = convertToVectorData(chatModelSchemas);
// 分批处理
int batchSize = 20;
int total = 0;
for (int i = 0; i < vectorDataList.size(); i += batchSize) {
int endIndex = Math.min(i + batchSize, vectorDataList.size());
List<VectorSaveReq.VectorData> batch = vectorDataList.subList(i, endIndex);
try {
VectorSaveReq req = new VectorSaveReq();
req.setCollectionName(DataAgentConstants.SCHEMA_COLLECTION_NAME);
req.setDataList(batch);
vectorService.saveVector(req);
total += endIndex - i;
} catch (Exception e) {
log.error("批量保存向量数据失败{}", e.getMessage(), e);
throw new RuntimeException("批量保存向量数据失败");
}
}
return total;
}
private List<VectorSaveReq.VectorData> convertToVectorData(List<ChatModelSchema> schemaList) {
List<VectorSaveReq.VectorData> allVectors = new ArrayList<>();
for (ChatModelSchema schema : schemaList) {
String[] uuids = schema.getVectorUuid().split(",");
addVectorSaveData(allVectors, schema, schema.getColumnName(), uuids[0]);
addVectorSaveData(allVectors, schema, schema.getSynonyms(), uuids[1]);
addVectorSaveData(allVectors, schema, schema.getColumnComment(), uuids[2]);
if (!StandardColumnType.DECIMAL.name().equalsIgnoreCase(schema.getDataType())) {
//数值类型fewShot不参与向量化
addVectorSaveData(allVectors, schema, schema.getFewShot(), uuids[3]);
}
}
return allVectors;View on GitHub (pinned to 2417e0b8b6)