jayblanc opened a new pull request, #931:
URL: https://github.com/apache/unomi/pull/931

   ## Summary
   
   - This pull request fixes 
[UNOMI-1025](https://issues.apache.org/jira/browse/UNOMI-1025). 
[apache/unomi#746](https://github.com/apache/unomi/pull/746) 
([UNOMI-924](https://issues.apache.org/jira/browse/UNOMI-924)) made the health 
check endpoint accept concurrent calls, but it also removed the per-provider 
timeout.
   - Without a timeout, a search engine that keeps the TCP connection open but 
does not answer blocks the refresh thread with no limit. Every other call then 
gets the last cached result with no age limit. `/health/check` can thus return 
HTTP 200 and LIVE while the search engine does not answer.
   
   ## Changes
   
   - `HealthCheckService` runs the enabled providers in parallel in an 
executor, and waits for each result until one common deadline, 
`healthcheck.timeout` (400 ms by default). A provider that does not answer in 
time is cancelled and returns `provider.timeout()`. A refresh therefore lasts 
about one timeout, whatever the number of providers.
   - The cache age is checked again inside `cacheLock`, so a thread that waited 
for the lock does not run a second refresh.
   - The providers list is a `CopyOnWriteArrayList`, because `bind()` and 
`unbind()` change it while `refreshCache()` reads it.
   - `deactivate()` shuts the executor down.
   - The ElasticSearch and OpenSearch providers set the connect, connection 
request and socket timeouts of the `_cluster/health` request to 
`healthcheck.timeout`. A blocked call then ends, and it does not keep an 
executor thread.
   - `setConfig` is `protected` instead of `private`, so that the unit test can 
set the configuration. DS still calls it.
   
   ## Test plan
   
   - [x] `HealthCheckServiceTest` (new): a provider that never answers times 
out within the deadline, and the other providers answer.
   - [x] `HealthCheckServiceTest`: a second call within one second uses the 
cache.
   - [x] Without the change of `HealthCheckService`, the first test fails with 
"execution timed out after 2000 ms".
   - [x] `mvn test` in `extensions/healthcheck` passes: 42 tests, 0 failures.
   - [ ] `HealthCheckIT`, CI.
   


-- 
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]

Reply via email to