优化版本冲突导致无法写入
This commit is contained in:
@@ -46,18 +46,16 @@ def deal(actions, item):
|
|||||||
"_op_type": "update",
|
"_op_type": "update",
|
||||||
"_index": index_name,
|
"_index": index_name,
|
||||||
"_id": item['_id'],
|
"_id": item['_id'],
|
||||||
"doc": doc_info
|
"doc": doc_info,
|
||||||
|
"_retry_on_conflict": 5
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.acquire(timeout=60)
|
mutex.acquire(timeout=60)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
if len(actions) == 5000:
|
if len(actions) == 5000:
|
||||||
try:
|
helpers.bulk(es206_client.elastic_client, actions)
|
||||||
helpers.bulk(es206_client.elastic_client, actions)
|
count += len(actions)
|
||||||
count += len(actions)
|
log.info("更新:" + str(count))
|
||||||
log.info("更新:" + str(count))
|
|
||||||
except Exception as e:
|
|
||||||
log.error(e)
|
|
||||||
actions.clear()
|
actions.clear()
|
||||||
mutex.release()
|
mutex.release()
|
||||||
|
|
||||||
|
|||||||
@@ -58,18 +58,16 @@ def deal(actions, item):
|
|||||||
"_op_type": "update",
|
"_op_type": "update",
|
||||||
"_index": index_name,
|
"_index": index_name,
|
||||||
"_id": item['_id'],
|
"_id": item['_id'],
|
||||||
"doc": doc_info
|
"doc": doc_info,
|
||||||
|
"_retry_on_conflict": 5
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.acquire(timeout=60)
|
mutex.acquire(timeout=60)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
if len(actions) == 5000:
|
if len(actions) == 5000:
|
||||||
try:
|
helpers.bulk(es206_client.elastic_client, actions)
|
||||||
helpers.bulk(es206_client.elastic_client, actions)
|
count += len(actions)
|
||||||
count += len(actions)
|
log.info("更新:" + str(count))
|
||||||
log.info("更新:" + str(count))
|
|
||||||
except Exception as e:
|
|
||||||
log.error(e)
|
|
||||||
actions.clear()
|
actions.clear()
|
||||||
mutex.release()
|
mutex.release()
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ def save(actions, item):
|
|||||||
"_op_type": "update",
|
"_op_type": "update",
|
||||||
"_index": index_name,
|
"_index": index_name,
|
||||||
"_id": item['_id'],
|
"_id": item['_id'],
|
||||||
"doc": doc_info
|
"doc": doc_info,
|
||||||
|
"_retry_on_conflict": 5
|
||||||
}
|
}
|
||||||
mutex.acquire(timeout=60)
|
mutex.acquire(timeout=60)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
|
|||||||
@@ -46,18 +46,16 @@ def deal(actions, item):
|
|||||||
"_op_type": "update",
|
"_op_type": "update",
|
||||||
"_index": index_name,
|
"_index": index_name,
|
||||||
"_id": item['_id'],
|
"_id": item['_id'],
|
||||||
"doc": doc_info
|
"doc": doc_info,
|
||||||
|
"_retry_on_conflict": 5
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.acquire(timeout=60)
|
mutex.acquire(timeout=60)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
if len(actions) == 5000:
|
if len(actions) == 5000:
|
||||||
try:
|
helpers.bulk(es206_client.elastic_client, actions)
|
||||||
helpers.bulk(es206_client.elastic_client, actions)
|
count += len(actions)
|
||||||
count += len(actions)
|
log.info("更新:" + str(count))
|
||||||
log.info("更新:" + str(count))
|
|
||||||
except Exception as e:
|
|
||||||
log.error(e)
|
|
||||||
actions.clear()
|
actions.clear()
|
||||||
mutex.release()
|
mutex.release()
|
||||||
|
|
||||||
|
|||||||
@@ -55,18 +55,16 @@ def deal(actions, item):
|
|||||||
"_op_type": "update",
|
"_op_type": "update",
|
||||||
"_index": index_name,
|
"_index": index_name,
|
||||||
"_id": item['_id'],
|
"_id": item['_id'],
|
||||||
"doc": doc_info
|
"doc": doc_info,
|
||||||
|
"_retry_on_conflict": 5
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.acquire(timeout=60)
|
mutex.acquire(timeout=60)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
if len(actions) == 5000:
|
if len(actions) == 5000:
|
||||||
try:
|
helpers.bulk(es206_client.elastic_client, actions)
|
||||||
helpers.bulk(es206_client.elastic_client, actions)
|
count += len(actions)
|
||||||
count += len(actions)
|
log.info("更新:" + str(count))
|
||||||
log.info("更新:" + str(count))
|
|
||||||
except Exception as e:
|
|
||||||
log.error(e)
|
|
||||||
actions.clear()
|
actions.clear()
|
||||||
mutex.release()
|
mutex.release()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user