优化版本冲突导致无法写入

This commit is contained in:
shenjian@fangjia.com
2022-11-04 16:36:20 +08:00
parent ce6895f9e2
commit f236968712
5 changed files with 22 additions and 29 deletions
@@ -46,18 +46,16 @@ def deal(actions, item):
"_op_type": "update",
"_index": index_name,
"_id": item['_id'],
"doc": doc_info
"doc": doc_info,
"_retry_on_conflict": 5
}
mutex.acquire(timeout=60)
actions.append(action)
if len(actions) == 5000:
try:
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
log.info("更新:" + str(count))
except Exception as e:
log.error(e)
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
log.info("更新:" + str(count))
actions.clear()
mutex.release()
@@ -58,18 +58,16 @@ def deal(actions, item):
"_op_type": "update",
"_index": index_name,
"_id": item['_id'],
"doc": doc_info
"doc": doc_info,
"_retry_on_conflict": 5
}
mutex.acquire(timeout=60)
actions.append(action)
if len(actions) == 5000:
try:
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
log.info("更新:" + str(count))
except Exception as e:
log.error(e)
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
log.info("更新:" + str(count))
actions.clear()
mutex.release()
+2 -1
View File
@@ -95,7 +95,8 @@ def save(actions, item):
"_op_type": "update",
"_index": index_name,
"_id": item['_id'],
"doc": doc_info
"doc": doc_info,
"_retry_on_conflict": 5
}
mutex.acquire(timeout=60)
actions.append(action)
+5 -7
View File
@@ -46,18 +46,16 @@ def deal(actions, item):
"_op_type": "update",
"_index": index_name,
"_id": item['_id'],
"doc": doc_info
"doc": doc_info,
"_retry_on_conflict": 5
}
mutex.acquire(timeout=60)
actions.append(action)
if len(actions) == 5000:
try:
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
log.info("更新:" + str(count))
except Exception as e:
log.error(e)
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
log.info("更新:" + str(count))
actions.clear()
mutex.release()
+5 -7
View File
@@ -55,18 +55,16 @@ def deal(actions, item):
"_op_type": "update",
"_index": index_name,
"_id": item['_id'],
"doc": doc_info
"doc": doc_info,
"_retry_on_conflict": 5
}
mutex.acquire(timeout=60)
actions.append(action)
if len(actions) == 5000:
try:
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
log.info("更新:" + str(count))
except Exception as e:
log.error(e)
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
log.info("更新:" + str(count))
actions.clear()
mutex.release()