{"action":"created","comment":{"url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/comments/37108687","id":37108687,"diff_hunk":"@@ -66,52 +69,50 @@ def run(output_queue)\n     start_buffer_broker(output_queue)\n \n     while true do\n-      begin\n-        # Wrapping the accept call into a CircuitBreaker\n-        if @circuit_breaker.closed?\n-          connection = @lumberjack.accept # Blocking call that creates a new connection\n+      # Wrappingu the accept call into a CircuitBreaker\n+      if @circuit_breaker.closed?\n+        connection = @lumberjack.accept # Blocking call that creates a new connection\n \n-          invoke(connection, codec.clone) do |_codec, line, fields|\n-            _codec.decode(line) do |event|\n+        invoke(connection, @codec.clone) do |_codec, line, fields|\n+          _codec.decode(line) do |event|\n+            begin\n               decorate(event)\n               fields.each { |k,v| event[k] = v; v.force_encoding(Encoding::UTF_8) }\n-\n-              @circuit_breaker.execute { @buffered_queue << event }\n+              @circuit_breaker.execute { @buffered_queue.push(event, @timeout) }\n+            rescue => e\n+              raise e\n             end\n           end\n-        else\n-          @logger.warn(\"Lumberjack input: the pipeline is blocked, temporary refusing new connection.\")\n-          sleep(RECONNECT_BACKOFF_SLEEP)\n         end\n-        # When too many errors happen inside the circuit breaker it will throw \n-        # this exception and start refusing connection, we need to catch it but \n-        # it's safe to ignore.\n-      rescue LogStash::CircuitBreaker::OpenBreaker => e\n+      else\n+        @logger.warn(\"Lumberjack input: the pipeline is blocked, temporary refusing new connection.\")\n+        sleep(RECONNECT_BACKOFF_SLEEP)\n       end\n     end\n   rescue LogStash::ShutdownSignal\n     @logger.info(\"Lumberjack input: received ShutdownSignal\")\n-  rescue => e\n-    @logger.error(\"Lumberjack input: unhandled exception\", :exception => e, :backtrace => e.backtrace)\n   ensure\n     shutdown(output_queue)\n   end # def run\n \n   private\n-  def accept(&block)\n-    connection = @lumberjack.accept # Blocking call that creates a new connection\n-    block.call(connection, @codec.clone)\n-  end\n-\n-  private\n   def invoke(connection, codec, &block)\n     @threadpool.post do\n       begin\n+        # If any errors occur in from the events the connection should be closed in the \n+        # library ensure block and the exception will be handled here\n         connection.run do |fields|\n           block.call(codec, fields.delete(\"line\"), fields)\n         end\n-      rescue => e\n-        @logger.error(\"Exception in lumberjack input thread\", :exception => e)\n+\n+        # When too many errors happen inside the circuit breaker it will throw \n+        # this exception and start refusing connection, we need to catch it but \n+        # it's safe to ignore.\n+      rescue LogStash::CircuitBreaker::OpenBreaker,\n+        LogStash::CircuitBreaker::HalfOpenBreaker => e\n+        logger.warn(\"Lumberjack input: connection closed, backing off\", :exception => e.class)","path":"lib/logstash/inputs/lumberjack.rb","position":86,"original_position":86,"commit_id":"048491804c8ca62f902dbeef17fda290984052e5","original_commit_id":"048491804c8ca62f902dbeef17fda290984052e5","user":{"login":"ph","id":640,"avatar_url":"https://avatars.githubusercontent.com/u/640?v=3","gravatar_id":"","url":"https://api.github.com/users/ph","html_url":"https://github.com/ph","followers_url":"https://api.github.com/users/ph/followers","following_url":"https://api.github.com/users/ph/following{/other_user}","gists_url":"https://api.github.com/users/ph/gists{/gist_id}","starred_url":"https://api.github.com/users/ph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ph/subscriptions","organizations_url":"https://api.github.com/users/ph/orgs","repos_url":"https://api.github.com/users/ph/repos","events_url":"https://api.github.com/users/ph/events{/privacy}","received_events_url":"https://api.github.com/users/ph/received_events","type":"User","site_admin":false},"body":"@jordansissel Something like this?\r\n```ruby\r\nlogger.warn(\"Lumberjack input: The circuit breaker has detected a slowdown in the pipeline, the input is closing the current connection and rejecting new connection until the pipeline recover.\", :exception => e.class)\r\n```\r\n","created_at":"2015-08-14T19:05:27Z","updated_at":"2015-08-14T19:05:27Z","html_url":"https://github.com/logstash-plugins/logstash-input-lumberjack/pull/43#discussion_r37108687","pull_request_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/43","_links":{"self":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/comments/37108687"},"html":{"href":"https://github.com/logstash-plugins/logstash-input-lumberjack/pull/43#discussion_r37108687"},"pull_request":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/43","id":42034269,"html_url":"https://github.com/logstash-plugins/logstash-input-lumberjack/pull/43","diff_url":"https://github.com/logstash-plugins/logstash-input-lumberjack/pull/43.diff","patch_url":"https://github.com/logstash-plugins/logstash-input-lumberjack/pull/43.patch","issue_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/issues/43","number":43,"state":"open","locked":false,"title":"Reorganize the errors handling","user":{"login":"ph","id":640,"avatar_url":"https://avatars.githubusercontent.com/u/640?v=3","gravatar_id":"","url":"https://api.github.com/users/ph","html_url":"https://github.com/ph","followers_url":"https://api.github.com/users/ph/followers","following_url":"https://api.github.com/users/ph/following{/other_user}","gists_url":"https://api.github.com/users/ph/gists{/gist_id}","starred_url":"https://api.github.com/users/ph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ph/subscriptions","organizations_url":"https://api.github.com/users/ph/orgs","repos_url":"https://api.github.com/users/ph/repos","events_url":"https://api.github.com/users/ph/events{/privacy}","received_events_url":"https://api.github.com/users/ph/received_events","type":"User","site_admin":false},"body":"This changes introduce a new way to do the errors handling,\r\neverytime that the circuit breaker doesn't run a piece of code we will\r\nstill throw a `HalfOpen` exception. In the lumberjack input case this\r\nallow the lumberjack library to know that something was wrong with the\r\npacket and stop the connection. Stopping the connection will force the\r\nclient to do a retransmit of the payload.\r\n","created_at":"2015-08-10T15:44:35Z","updated_at":"2015-08-14T19:05:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7f966f226ed98f75fa6f14c1ecefe965ffc1d05","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/43/commits","review_comments_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/43/comments","review_comment_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/issues/43/comments","statuses_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/statuses/048491804c8ca62f902dbeef17fda290984052e5","head":{"label":"ph:fix/drop-events","ref":"fix/drop-events","sha":"048491804c8ca62f902dbeef17fda290984052e5","user":{"login":"ph","id":640,"avatar_url":"https://avatars.githubusercontent.com/u/640?v=3","gravatar_id":"","url":"https://api.github.com/users/ph","html_url":"https://github.com/ph","followers_url":"https://api.github.com/users/ph/followers","following_url":"https://api.github.com/users/ph/following{/other_user}","gists_url":"https://api.github.com/users/ph/gists{/gist_id}","starred_url":"https://api.github.com/users/ph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ph/subscriptions","organizations_url":"https://api.github.com/users/ph/orgs","repos_url":"https://api.github.com/users/ph/repos","events_url":"https://api.github.com/users/ph/events{/privacy}","received_events_url":"https://api.github.com/users/ph/received_events","type":"User","site_admin":false},"repo":{"id":26817613,"name":"logstash-input-lumberjack","full_name":"ph/logstash-input-lumberjack","owner":{"login":"ph","id":640,"avatar_url":"https://avatars.githubusercontent.com/u/640?v=3","gravatar_id":"","url":"https://api.github.com/users/ph","html_url":"https://github.com/ph","followers_url":"https://api.github.com/users/ph/followers","following_url":"https://api.github.com/users/ph/following{/other_user}","gists_url":"https://api.github.com/users/ph/gists{/gist_id}","starred_url":"https://api.github.com/users/ph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ph/subscriptions","organizations_url":"https://api.github.com/users/ph/orgs","repos_url":"https://api.github.com/users/ph/repos","events_url":"https://api.github.com/users/ph/events{/privacy}","received_events_url":"https://api.github.com/users/ph/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ph/logstash-input-lumberjack","description":null,"fork":true,"url":"https://api.github.com/repos/ph/logstash-input-lumberjack","forks_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/forks","keys_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/teams","hooks_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/hooks","issue_events_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/issues/events{/number}","events_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/events","assignees_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/assignees{/user}","branches_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/branches{/branch}","tags_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/tags","blobs_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/git/refs{/sha}","trees_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/statuses/{sha}","languages_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/languages","stargazers_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/stargazers","contributors_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/contributors","subscribers_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/subscribers","subscription_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/subscription","commits_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/commits{/sha}","git_commits_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/git/commits{/sha}","comments_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/comments{/number}","issue_comment_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/issues/comments{/number}","contents_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/contents/{+path}","compare_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/merges","archive_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/downloads","issues_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/issues{/number}","pulls_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/pulls{/number}","milestones_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/milestones{/number}","notifications_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/labels{/name}","releases_url":"https://api.github.com/repos/ph/logstash-input-lumberjack/releases{/id}","created_at":"2014-11-18T16:10:29Z","updated_at":"2015-05-05T19:13:01Z","pushed_at":"2015-08-11T14:38:02Z","git_url":"git://github.com/ph/logstash-input-lumberjack.git","ssh_url":"git@github.com:ph/logstash-input-lumberjack.git","clone_url":"https://github.com/ph/logstash-input-lumberjack.git","svn_url":"https://github.com/ph/logstash-input-lumberjack","homepage":null,"size":190,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"logstash-plugins:master","ref":"master","sha":"7c832e458644b2117043b489ac94f281f5d5978b","user":{"login":"logstash-plugins","id":8961934,"avatar_url":"https://avatars.githubusercontent.com/u/8961934?v=3","gravatar_id":"","url":"https://api.github.com/users/logstash-plugins","html_url":"https://github.com/logstash-plugins","followers_url":"https://api.github.com/users/logstash-plugins/followers","following_url":"https://api.github.com/users/logstash-plugins/following{/other_user}","gists_url":"https://api.github.com/users/logstash-plugins/gists{/gist_id}","starred_url":"https://api.github.com/users/logstash-plugins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/logstash-plugins/subscriptions","organizations_url":"https://api.github.com/users/logstash-plugins/orgs","repos_url":"https://api.github.com/users/logstash-plugins/repos","events_url":"https://api.github.com/users/logstash-plugins/events{/privacy}","received_events_url":"https://api.github.com/users/logstash-plugins/received_events","type":"Organization","site_admin":false},"repo":{"id":25312483,"name":"logstash-input-lumberjack","full_name":"logstash-plugins/logstash-input-lumberjack","owner":{"login":"logstash-plugins","id":8961934,"avatar_url":"https://avatars.githubusercontent.com/u/8961934?v=3","gravatar_id":"","url":"https://api.github.com/users/logstash-plugins","html_url":"https://github.com/logstash-plugins","followers_url":"https://api.github.com/users/logstash-plugins/followers","following_url":"https://api.github.com/users/logstash-plugins/following{/other_user}","gists_url":"https://api.github.com/users/logstash-plugins/gists{/gist_id}","starred_url":"https://api.github.com/users/logstash-plugins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/logstash-plugins/subscriptions","organizations_url":"https://api.github.com/users/logstash-plugins/orgs","repos_url":"https://api.github.com/users/logstash-plugins/repos","events_url":"https://api.github.com/users/logstash-plugins/events{/privacy}","received_events_url":"https://api.github.com/users/logstash-plugins/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/logstash-plugins/logstash-input-lumberjack","description":null,"fork":false,"url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack","forks_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/forks","keys_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/teams","hooks_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/hooks","issue_events_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/issues/events{/number}","events_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/events","assignees_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/assignees{/user}","branches_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/branches{/branch}","tags_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/tags","blobs_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/git/refs{/sha}","trees_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/statuses/{sha}","languages_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/languages","stargazers_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/stargazers","contributors_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/contributors","subscribers_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/subscribers","subscription_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/subscription","commits_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/commits{/sha}","git_commits_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/git/commits{/sha}","comments_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/comments{/number}","issue_comment_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/issues/comments{/number}","contents_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/contents/{+path}","compare_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/merges","archive_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/downloads","issues_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/issues{/number}","pulls_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls{/number}","milestones_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/milestones{/number}","notifications_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/labels{/name}","releases_url":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/releases{/id}","created_at":"2014-10-16T17:03:23Z","updated_at":"2015-06-18T17:26:31Z","pushed_at":"2015-08-11T14:38:03Z","git_url":"git://github.com/logstash-plugins/logstash-input-lumberjack.git","ssh_url":"git@github.com:logstash-plugins/logstash-input-lumberjack.git","clone_url":"https://github.com/logstash-plugins/logstash-input-lumberjack.git","svn_url":"https://github.com/logstash-plugins/logstash-input-lumberjack","homepage":null,"size":387,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":23,"forks":10,"open_issues":23,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/43"},"html":{"href":"https://github.com/logstash-plugins/logstash-input-lumberjack/pull/43"},"issue":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/issues/43"},"comments":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/logstash-plugins/logstash-input-lumberjack/statuses/048491804c8ca62f902dbeef17fda290984052e5"}}}}