Checks if `endpoint` is failed on a healthy server or not. Returns true if we need to refresh the location cache for the endpoint.
| 2910 | // Checks if `endpoint` is failed on a healthy server or not. Returns true if we need to refresh the location cache for |
| 2911 | // the endpoint. |
| 2912 | bool checkOnlyEndpointFailed(const Database& cx, const Endpoint& endpoint) { |
| 2913 | if (IFailureMonitor::failureMonitor().onlyEndpointFailed(endpoint)) { |
| 2914 | // This endpoint is failed, but the server is still healthy. There are two cases this can happen: |
| 2915 | // - There is a recent bounce in the cluster where the endpoints in SSes get updated. |
| 2916 | // - The SS is failed and terminated on a server, but the server is kept running. |
| 2917 | // To account for the first case, we invalidate the cache and issue GetKeyLocation requests to the proxy to |
| 2918 | // update the cache with the new SS points. However, if the failure is caused by the second case, the |
| 2919 | // requested key location will continue to be the failed endpoint until the data movement is finished. But |
| 2920 | // every read will generate a GetKeyLocation request to the proxies (and still getting the failed endpoint |
| 2921 | // back), which may overload the proxy and affect data movement speed. Therefore, we only refresh the |
| 2922 | // location cache for short period of time, and after the initial grace period that we keep retrying |
| 2923 | // resolving key location, we will slow it down to resolve it only once every |
| 2924 | // `LOCATION_CACHE_FAILED_ENDPOINT_RETRY_INTERVAL`. |
| 2925 | cx->setFailedEndpointOnHealthyServer(endpoint); |
| 2926 | const auto& failureInfo = cx->getEndpointFailureInfo(endpoint); |
| 2927 | ASSERT(failureInfo.present()); |
| 2928 | if (now() - failureInfo.get().startTime < CLIENT_KNOBS->LOCATION_CACHE_ENDPOINT_FAILURE_GRACE_PERIOD || |
| 2929 | now() - failureInfo.get().lastRefreshTime > CLIENT_KNOBS->LOCATION_CACHE_FAILED_ENDPOINT_RETRY_INTERVAL) { |
| 2930 | cx->updateFailedEndpointRefreshTime(endpoint); |
| 2931 | return true; |
| 2932 | } |
| 2933 | } else { |
| 2934 | cx->clearFailedEndpointOnHealthyServer(endpoint); |
| 2935 | } |
| 2936 | return false; |
| 2937 | } |
| 2938 | |
| 2939 | template <class F> |
| 2940 | Future<KeyRangeLocationInfo> getKeyLocation(Database const& cx, |
no test coverage detected