Repository navigation
Fix #207: avoid server stall when a client stops answering broadcasts - #208
Merged
Merged
Conversation
The broadcast reply deadlines (slow client detection) were checked by the same thread that expires TTL entries, after waiting for the expiration invalidations to complete. When a client stopped answering, an expiration invalidation never completed, the expirer thread blocked forever and the deadlines were no longer checked: the slow client was never disconnected and every operation waiting for it hung, stalling the whole server. CacheServer - Check broadcast reply deadlines on a dedicated thread (cache-server-idle-connections-thread) which never waits for cache operations. - The expirer no longer waits for the expiration invalidations: keys whose expiration is in progress are tracked and skipped, so an invalidation stuck behind an application lock (which has no timeout) or a slow client only delays the expiration of its own key. At most 1000 new expirations are started on each run. - Both background loops survive unexpected errors instead of dying silently. - Reject non positive expirer / idle connections check periods. NettyChannel / NettyConnector - Bound the wait for the socket close (blazingcache.nettychannel.closetimeout, default 10s) and never wait when invoked from the channel event loop, where Netty forbids blocking (e.g. SSL close_notify). - Always fail the pending reply callbacks on close, even if closing the socket fails. - Make close() run exactly once and avoid waiting twice for the same socket on the client side. ServerMain - New server.properties settings: expirer.period and idle.connections.check.period (default 1000 ms). Tests - ExpirerBlockedBySlowClientTest: a client never acking invalidations is disconnected and the expired entry cleaned up. - ExpirerBlockedByLockTest: an expired entry locked by a client does not block the expiration of other entries. - CacheServerPeriodsConfigurationTest: periods validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #207
Problem
The broadcast reply deadlines (slow client detection) were checked by
cache-server-expire-thread, the same thread that invalidates TTL-expired entries, and only after waiting (CountDownLatch.await()) for those invalidations to complete.When a client stopped answering, an expiration invalidation sent to it never completed: the expirer thread blocked forever, the deadlines were no longer checked, the slow client was never disconnected and every operation waiting for it hung, stalling the whole server.
Changes
CacheServer
cache-server-idle-connections-thread) that never waits for cache operations.NettyChannel / NettyConnector
blazingcache.nettychannel.closetimeoutsystem property, default 10s). On timeout the wait is abandoned: the close is already scheduled and Netty completes it later.close_notify).close()runs exactly once, and the client no longer waits twice for the same socket.ServerMain / server.properties
expirer.periodandidle.connections.check.period(default 1000 ms).Tests
ExpirerBlockedBySlowClientTest: a client that never acks invalidations is disconnected and the expired entry is cleaned up (fails on master).ExpirerBlockedByLockTest: an expired entry locked by a client does not block the expiration of other entries (fails on master).CacheServerPeriodsConfigurationTest: periods validation.apache-rat:check,spotbugs:checkand the core/jcache test suites pass on JDK 11.