优化版本冲突导致无法写入
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user