JuliaWeb/GitHub.jl

POST operations need to handle intermittent network failure.

Open

#106 opened on Mar 17, 2018

 (5 comments) (2 reactions) (0 assignees)Julia (62 forks)github user discovery
help wantedpriority

Repository metrics

Stars
 (174 stars)
PR merge metrics
 (Avg merge 2d 9h) (1 merged PR in 30d)

Description

The GitHub doc says that they have been careful to use HTTP methods with semantics appropriate to the API operations.

HTTP.jl retries most request automatically in the event of network failure. However, POST operations are not generally idempotent and cannot be automatically retried. GitHub.jl should implement system-state-aware retry loops around POST requests. i.e. when a POST operation throws an HTTP.IOError GitHub.jl should retry the operation in a way that avoids duplicate changes to system state.

In the case of the create_status operation that is the subject of https://github.com/JuliaWeb/HTTP.jl/issues/220, POST /repos/:owner/:repo/statuses/:sha, it seems that double-posting would create two statuses, https://developer.github.com/v3/repos/statuses/, so in the event of a failure, the GitHub.jl create_status function should do a GET to check if the status was created before retrying (or, if duplicate statuses are not considered harmful to overall system correctness, just set retry_non_idempotent=true).

https://github.com/JuliaWeb/GitHub.jl/blob/beb3659dc0d43b29354fcf909de1b453e248b37c/src/repositories/statuses.jl#L30-L33

See also https://github.com/JuliaWeb/HTTP.jl/issues/214.

This issue may apply in other places that use gh_post_json.

Contributor guide