2、出了事了,才找到根因。
當今天調試的時候,把批量數調到最小1的時候,ES中仍然沒有導入資料。
這才意識到,不對,是不是單條資料就有問題?
後改到單條資料(不走批量),直接插入,報錯如下:
單條導入報錯如下:
[INFO]-[com.es.process.ESProcess] err
{“root_cause”:[{“type”:”mapper_parsing_exception”,”reason”:”Field
[_id] is a metadata field and cannot be added inside a document. Use
the index API request
parameters.”}],”type”:”mapper_parsing_exception”,”reason”:”Field [_id]
is a metadata field and cannot be added inside a document. Use the
index API request parameters.”}
比較直覺,字段的問題。
逐個字段修複後,問題不在。
批量值改成較大值100後,也能較快導入。
3、走的彎路
3.1 源碼附近找答案,無果。
Jest Bulk Github 源碼位置:
if (isHttpSuccessful(statusCode)) {
if(jsonMap.has("errors") && jsonMap.get("errors").getAsBoolean())
{
result.setSucceeded(false);
result.setErrorMessage("One or more of the items in the Bulk request failed, check BulkResult.getItems() for more information.");
log.debug("Bulk operation failed due to one or more failed actions within the Bulk request");
} else {
result.setSucceeded(true);
log.debug("Bulk operation was successfull");
}
1
2
3
4
5
6
7
8
9
10
源碼中,有明确告訴:
批量操作失敗,會列印Bulk operation failed錯誤。但是沒有明确告訴,錯在哪裡?
更進一步,有告訴:
BulkResult.getItems() for more information
調試後,列印日志如下:
error = [io.searchbox.core. BulkResultBulkResultItem@48782849,io.searchbox.core.BulkResultBulkResultItem@48782849,io.searchbox.core.BulkResultBulkResultItem@6e2561df,
io.searchbox.core.BulkResult$BulkResultItem@1196e6ad,
貌似,還是沒有根本錯誤的原因。
3.2 Google/Stackoverflow 查詢
類似問題,比對度少,無果。
3.3 想想可能出錯的場景?
1、是不是要大量doc沒有formerge導緻的?
和這個沒有本質關聯。
2、是不是短時間内大量更新,導緻的沖突。
不會的,ES是_version版本控制的。
3、是不是批量操作量太大了,超過隊列長度大小。
逐漸減少到1,才找到根本原因。
4、小結
1、批量的錯誤,要縮小範圍調試,單條資料看有沒有問題?
2、跟蹤排查,轉化思路,不放棄,直到定位本質原因。
加入知識星球,更短時間更快習得更多幹貨!
2018-05-25 22:47 思于家中床前
作者:銘毅天下
轉載請标明出處,原文位址:
http://blog.csdn.net/laoyang360/article/details/52244917如果感覺本文對您有幫助,請點選‘頂’支援一下,您的支援是我堅持寫作最大的動力,謝謝!