{"action":"created","issue":{"url":"https://api.github.com/repos/mrniko/redisson/issues/198","labels_url":"https://api.github.com/repos/mrniko/redisson/issues/198/labels{/name}","comments_url":"https://api.github.com/repos/mrniko/redisson/issues/198/comments","events_url":"https://api.github.com/repos/mrniko/redisson/issues/198/events","html_url":"https://github.com/mrniko/redisson/issues/198","id":97838869,"number":198,"title":"Redisson calls do not time out and very long cache times depending on ttl setting","user":{"login":"oleg-gr","id":3584701,"avatar_url":"https://avatars.githubusercontent.com/u/3584701?v=3","gravatar_id":"","url":"https://api.github.com/users/oleg-gr","html_url":"https://github.com/oleg-gr","followers_url":"https://api.github.com/users/oleg-gr/followers","following_url":"https://api.github.com/users/oleg-gr/following{/other_user}","gists_url":"https://api.github.com/users/oleg-gr/gists{/gist_id}","starred_url":"https://api.github.com/users/oleg-gr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleg-gr/subscriptions","organizations_url":"https://api.github.com/users/oleg-gr/orgs","repos_url":"https://api.github.com/users/oleg-gr/repos","events_url":"https://api.github.com/users/oleg-gr/events{/privacy}","received_events_url":"https://api.github.com/users/oleg-gr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mrniko/redisson/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/mrniko/redisson/milestones/10","html_url":"https://github.com/mrniko/redisson/milestones/2.1.0","labels_url":"https://api.github.com/repos/mrniko/redisson/milestones/10/labels","id":1212372,"number":10,"title":"2.1.0","description":"","creator":{"login":"mrniko","id":1104661,"avatar_url":"https://avatars.githubusercontent.com/u/1104661?v=3","gravatar_id":"","url":"https://api.github.com/users/mrniko","html_url":"https://github.com/mrniko","followers_url":"https://api.github.com/users/mrniko/followers","following_url":"https://api.github.com/users/mrniko/following{/other_user}","gists_url":"https://api.github.com/users/mrniko/gists{/gist_id}","starred_url":"https://api.github.com/users/mrniko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrniko/subscriptions","organizations_url":"https://api.github.com/users/mrniko/orgs","repos_url":"https://api.github.com/users/mrniko/repos","events_url":"https://api.github.com/users/mrniko/events{/privacy}","received_events_url":"https://api.github.com/users/mrniko/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":7,"state":"closed","created_at":"2015-07-17T06:59:30Z","updated_at":"2015-08-03T17:27:20Z","due_on":null,"closed_at":"2015-08-03T17:27:20Z"},"comments":80,"created_at":"2015-07-29T01:53:03Z","updated_at":"2015-09-16T05:13:23Z","closed_at":null,"body":"Hi, while developing using redisson some problems with timeouts and cache times are experienced.\r\n\r\n1) Consider the following scenario:\r\n```\r\ntry {\r\n     node = configCacheBusinessLogic.get();\r\n} catch (RedisException e) {\r\n     log.warn(\"Failed to get from cache, fall back to database\", e);\r\n     node = configService.get();\r\n}\r\n```\r\n2) In ConfigCacheBusinessLogic:\r\n```\r\n@Cacheable(value = CACHE_NAME, key = CACHE_KEY_SPEL)\r\npublic JsonNode get() throws AbstractCustomException {\r\n    //configService.get() is database logic wrapped in @Transactional\r\n    return configService.get();\r\n}\r\n```\r\n3) @Cacheable uses a class that extends Spring's Cache: \r\n````\r\n@Override\r\npublic ValueWrapper get(Object key) {\r\n   PerformanceLogHelper.startTimer(CACHE_TIME);\r\n   try {\r\n       RBucket bucket = redisson.getBucket((String) key);\r\n       Object value = bucket.get();\r\n       return toWrapper(value);\r\n    } finally {\r\n        PerformanceLogHelper.stopTimer(CACHE_TIME);\r\n    }\r\n}\r\n```\r\n\r\nNow there are several problems here. Timeout exceptions are being thrown, but seemingly at random times ignoring the timeout setting of redisson. It is also somehow being affected by ttl setting as the shorter ttl yields lower cache times, as well as the frequency of hitting the cache. You can see it from the following graphs of CACHE_TIME timer:\r\n1. Long TTL setting, and around 4-5 queries per minute (cache time goes as high as 800,000 ms):\r\n![long ttl not many queries](https://cloud.githubusercontent.com/assets/3584701/8947897/ba086774-35db-11e5-9314-3c844218bce6.png)\r\n2 . With long TTL setting and around 200 queries per minute, cache times also go as high as 800,000 ms but there are fewer spikes than in case 1 (sorry no screenshot)\r\n3. Short TTL setting, around 4-5 queries per minute (cache time goes as high as 800 ms):\r\n![short tll not many queries](https://cloud.githubusercontent.com/assets/3584701/8947906/d30ba498-35db-11e5-8491-2c5e0683e31f.png)\r\n4. Short TTL setting, around 200 queries per minute (cache time goes as high as 1000 ms but very rarely):\r\n![short ttl many queries](https://cloud.githubusercontent.com/assets/3584701/8947916/eacb9976-35db-11e5-8878-d5591f1ac113.png)\r\n\r\nSo to summarize:\r\n\r\n| TTL   | Queries per minute | Max cache time | Cache time spikes | Picture in the previous list |\r\n|-------|--------------------|----------------|-------------------|------------------------------|\r\n| Long  | 4-5                | 800,000        | Many              | 1                            |\r\n| Long  | ~200               | 800,000        | Few               | 2 (no pic)                   |\r\n| Short | 4-5                | 800            | Many              | 3                            |\r\n| Short | ~200               | 1000           | Few               | 4                            |\r\n\r\nIn all cases the timeout was set to 100ms, 3 attempts with 100ms interval. In all the cases in the end requests succeed to fall over to the database (either through a timeout error or through returning null). Regardless, the timeout is not being thrown according to the settings. Please let me know if you might know the cause of the issue. Thoroughly investigated the code on this side and it seems like the issue is in redisson. Let me know if you need more context"},"comment":{"url":"https://api.github.com/repos/mrniko/redisson/issues/comments/140628186","html_url":"https://github.com/mrniko/redisson/issues/198#issuecomment-140628186","issue_url":"https://api.github.com/repos/mrniko/redisson/issues/198","id":140628186,"user":{"login":"oleg-gr","id":3584701,"avatar_url":"https://avatars.githubusercontent.com/u/3584701?v=3","gravatar_id":"","url":"https://api.github.com/users/oleg-gr","html_url":"https://github.com/oleg-gr","followers_url":"https://api.github.com/users/oleg-gr/followers","following_url":"https://api.github.com/users/oleg-gr/following{/other_user}","gists_url":"https://api.github.com/users/oleg-gr/gists{/gist_id}","starred_url":"https://api.github.com/users/oleg-gr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleg-gr/subscriptions","organizations_url":"https://api.github.com/users/oleg-gr/orgs","repos_url":"https://api.github.com/users/oleg-gr/repos","events_url":"https://api.github.com/users/oleg-gr/events{/privacy}","received_events_url":"https://api.github.com/users/oleg-gr/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T05:13:23Z","updated_at":"2015-09-16T05:13:23Z","body":"Also, not sure why but there is a big CPU jump when trying to reconnect channel that hasn't been used for a while: from 0.5% to 30% usage"}}