{"action":"created","issue":{"url":"https://api.github.com/repos/fluent/fluentd/issues/568","labels_url":"https://api.github.com/repos/fluent/fluentd/issues/568/labels{/name}","comments_url":"https://api.github.com/repos/fluent/fluentd/issues/568/comments","events_url":"https://api.github.com/repos/fluent/fluentd/issues/568/events","html_url":"https://github.com/fluent/fluentd/pull/568","id":64849895,"number":568,"title":"fix try_flush_interval < 1 and queued_chunk_flush_interval < 1 to work","user":{"login":"sonots","id":2290461,"avatar_url":"https://avatars.githubusercontent.com/u/2290461?v=3","gravatar_id":"","url":"https://api.github.com/users/sonots","html_url":"https://github.com/sonots","followers_url":"https://api.github.com/users/sonots/followers","following_url":"https://api.github.com/users/sonots/following{/other_user}","gists_url":"https://api.github.com/users/sonots/gists{/gist_id}","starred_url":"https://api.github.com/users/sonots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonots/subscriptions","organizations_url":"https://api.github.com/users/sonots/orgs","repos_url":"https://api.github.com/users/sonots/repos","events_url":"https://api.github.com/users/sonots/events{/privacy}","received_events_url":"https://api.github.com/users/sonots/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-27T20:55:22Z","updated_at":"2015-03-27T20:55:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/fluent/fluentd/pulls/568","html_url":"https://github.com/fluent/fluentd/pull/568","diff_url":"https://github.com/fluent/fluentd/pull/568.diff","patch_url":"https://github.com/fluent/fluentd/pull/568.patch"},"body":"We were supposed to support `try_flush_interval < 1` and `queue_chunk_flush_interval < 1`, but the interval to call `try_flush` was still minimum 1 sec because `Engine.now` is `Time.now.to_i`. \r\n\r\nIllustration: The problem of the old logic:\r\n\r\n```ruby\r\n        until @finish\r\n          time = Engine.now\r\n\r\n          if @next_time <= time # (4) have to wait to be 1427488240.1 <= 1427488241\r\n            @mutex.unlock\r\n            begin\r\n              @next_time = @output.try_flush # (1) 1427488240.1\r\n            ensure\r\n              @mutex.lock\r\n            end\r\n            next_wait = @next_time - Engine.now # (2) 0.1\r\n          else\r\n            next_wait = @next_time - time\r\n          end\r\n\r\n          # (3) will wait 0.1 sec\r\n          cond_wait(next_wait) if next_wait > 0\r\n        end\r\n```\r\n\r\n`@next_time` can be like `1427488240.1` when `queued_chunk_flush_interval 0.1`. \r\nBut, `time` exceeds the `@next_time` only when it became ``1427488241` (1 sec passed) because `Engine.now` is integer. \r\n"},"comment":{"url":"https://api.github.com/repos/fluent/fluentd/issues/comments/87089680","html_url":"https://github.com/fluent/fluentd/pull/568#issuecomment-87089680","issue_url":"https://api.github.com/repos/fluent/fluentd/issues/568","id":87089680,"user":{"login":"sonots","id":2290461,"avatar_url":"https://avatars.githubusercontent.com/u/2290461?v=3","gravatar_id":"","url":"https://api.github.com/users/sonots","html_url":"https://github.com/sonots","followers_url":"https://api.github.com/users/sonots/followers","following_url":"https://api.github.com/users/sonots/following{/other_user}","gists_url":"https://api.github.com/users/sonots/gists{/gist_id}","starred_url":"https://api.github.com/users/sonots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonots/subscriptions","organizations_url":"https://api.github.com/users/sonots/orgs","repos_url":"https://api.github.com/users/sonots/repos","events_url":"https://api.github.com/users/sonots/events{/privacy}","received_events_url":"https://api.github.com/users/sonots/received_events","type":"User","site_admin":false},"created_at":"2015-03-27T20:55:59Z","updated_at":"2015-03-27T20:55:59Z","body":"cc: @shyouhei"}}