bzp2010 commented on code in PR #2650:
URL: https://github.com/apache/apisix-dashboard/pull/2650#discussion_r1006380361
##########
api/cmd/root.go:
##########
@@ -81,3 +89,57 @@ func manageAPI() error {
}
return nil
}
+
+func etcdConnectionChecker() context.CancelFunc {
+ ctx, cancel := context.WithCancel(context.TODO())
+ unavailableTimes := 0
+
+ go func() {
+ etcdClient := storage.GenEtcdStorage().GetClient()
+ for {
+ select {
+ case <-time.Tick(10 * time.Second):
+ sCtx, sCancel :=
context.WithTimeout(context.TODO(), 5*time.Second)
+ err := etcdClient.Sync(sCtx)
Review Comment:
The connection can be automatically restored, but the behavior of watch is
unobservable, and sometimes watch is incapacitated, but it still does not
actively quit. There is no API to actively know which watchers are currently
available and what is the state of those watchers.
This is a complete black box for its applicators, the entire documentation
of etcd mentions that its connections are self-healing and watch will not lose
any data, but it does happen in our environment.
I think this is really necessary, and if you don't think it's appropriate,
we can use a less expensive way than sync requests, which is to implement it
using etcd client's internal connection state monitor,
client.getActiveConnection(), which will not initiate the request, but still
get the connection state.
**IMHO, for the uncertain behavior in the etcd client (it is indeed a black
box), where all the grpc stream details are hidden and the documentation does
not match the actual behavior, an active health checking mechanism independent
of the internal mechanism is a must.**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]