Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh with fresh sequence token #56

Merged
merged 2 commits into from
Oct 5, 2018
Merged

Refresh with fresh sequence token #56

merged 2 commits into from
Oct 5, 2018

Conversation

mstovicek
Copy link
Contributor

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix

  • What is the current behavior? (You can also link to an open issue here)

An exception about an invalid CloudWatch log stream sequence token appears while running a long script in Docker. I suspect another process creates a new sequence token and invalidates the one used by a Docker instance. This will probably happen when running a cluster of few web instances trying to write logs in a same time too.

Exception:

23:03:37 ERROR [console] Error thrown while running command "*****". 
Message: "Error executing "PutLogEvents" on "https://logs.eu-central-1.amazonaws.com"; 
AWS HTTP error: Client error: `POST https://logs.eu-central-1.amazonaws.com` resulted in a `400 Bad Request` response:
{
  "__type": "InvalidSequenceTokenException",
  "expectedSequenceToken": "49588220171152916907562770980898637167375952589803759 (truncated...) InvalidSequenceTokenException (client): The given sequenceToken is invalid. The next expected sequenceToken is: 49588220171152916907562770980898637167375952589803759074"
}
{
  "__type": "InvalidSequenceTokenException",
  "expectedSequenceToken": "49588220171152916907562770980898637167375952589803759074",
  "message": "The given sequenceToken is invalid. The next expected sequenceToken is: 49588220171152916907562770980898637167375952589803759074"
}
{
    "exception" => Aws\CloudWatchLogs\Exception\CloudWatchLogsException {},
    "command" => "***",
    "message" => "Error executing \"PutLogEvents\" on \"https://logs.eu-central-1.amazonaws.com\"; 
    AWS HTTP error: Client error: `POST https://logs.eu-central-1.amazonaws.com` resulted in a `400 Bad Request` response:
    {
        "__type": "InvalidSequenceTokenException",
        "expectedSequenceToken":
        49588220171152916907562770980898637167375952589803759 (truncated...)
        InvalidSequenceTokenException (client): The given sequenceToken is invalid. The next expected sequenceToken is: 49588220171152916907562770980898637167375952589803759074
    }
}
  • What is the new behavior (if this is a feature change)?

Handler retries to send entries to CloudWatch once an exception \Aws\CloudWatchLogs\Exception\CloudWatchLogsException is thrown by a client. It gets a fresh sequence token from CloudWatch log stream before retry.
It does not check the exact type of an exception simply because I did not notice another exception.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No breaking changes

  • Other information:

Hi Max,
we still use your library in our main project and we don't notice any troubles when running in for user requests 👍
I hope you will find a time to review and test this PR so we can upgrage to a new version.

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.9%) to 93.684% when pulling 14319c6 on buzzbird:retry-with-fresh-sequence-token into 4034b71 on maxbanton:master.

@coveralls
Copy link

coveralls commented Oct 5, 2018

Coverage Status

Coverage decreased (-3.9%) to 93.684% when pulling 905f883 on buzzbird:retry-with-fresh-sequence-token into 4034b71 on maxbanton:master.

@maxbanton maxbanton merged commit 419c94d into maxbanton:master Oct 5, 2018
@maxbanton
Copy link
Owner

Hi @mstovicek! Thanks for your PR, merged. Will publish new version soon.

@maxbanton
Copy link
Owner

New version 1.1.10 published! https://packagist.org/packages/maxbanton/cwh#v1.1.10

By the way, the library recently scored 400K of downloads! Congratulations to the whole community!

@mstovicek
Copy link
Contributor Author

Thank you for a very quick response, @maxbanton <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants