diff options
| author | fengweihao <[email protected]> | 2024-05-09 16:12:10 +0800 |
|---|---|---|
| committer | fengweihao <[email protected]> | 2024-05-09 16:12:10 +0800 |
| commit | c06c028715ab3951e5302a80203dfcb5764a7d06 (patch) | |
| tree | f9d288026221342eca0443a71ba3685c60b7c70e | |
| parent | adbf82d087f5aeac880c6b618300dd7172c78d86 (diff) | |
When the number of connection failures between swarmkv and consul accumulates to more than 8 times,reduce the recursive request frequency to the consul function.bugfix-tsg-21020
| -rw-r--r-- | src/swarmkv_keyspace.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/swarmkv_keyspace.c b/src/swarmkv_keyspace.c index 582cf52..8b74eea 100644 --- a/src/swarmkv_keyspace.c +++ b/src/swarmkv_keyspace.c @@ -226,6 +226,7 @@ struct ks_thread struct http_client *consul_client; int consul_slots_modify_idx; int consul_nodes_modify_idx; + int consul_connect_failed_idx; struct swarmkv_keyspace *ref_ks; struct event_base *evbase; //reference of swarmkv @@ -775,6 +776,11 @@ void watch_slots_changes_on_success(void *result, void *arg) void watch_slots_changes_on_fail(enum e_future_error err, const char * what, void * arg) { struct ks_thread *thr=(struct ks_thread*)arg; + thr->consul_connect_failed_idx++; + if(thr->consul_connect_failed_idx >= 8) + { + sleep(1); + } consul_watch_slots_changes_async(thr); } void consul_watch_slots_changes_async(struct ks_thread *thr) @@ -1008,6 +1014,11 @@ void watch_nodes_changes_on_success(void *result, void *arg) void watch_nodes_changes_on_fail(enum e_future_error err, const char * what, void * arg) { struct ks_thread *thr=(struct ks_thread*)arg; + thr->consul_connect_failed_idx++; + if(thr->consul_connect_failed_idx >= 8) + { + sleep(1); + } consul_watch_nodes_changes_async(thr); } void consul_watch_nodes_changes_async(struct ks_thread *thr) |
