summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2014-11-02 21:44:43 -0500
committerMicah Anderson <micah@riseup.net>2014-11-02 21:44:43 -0500
commit4c0d5673df02fe42e1bbadfee7d4ea1ca1f88e98 (patch)
treea29b5f148576c4c8393886e51a2a7e566d00fcee
parentf01b3586215bdc10f0067fa0f6d940be8e88bcea (diff)
retry 500 Internal Server Errors a few times in order to get past timing issues related to node deployment (#6287)
-rw-r--r--files/couch-doc-update16
1 files changed, 16 insertions, 0 deletions
diff --git a/files/couch-doc-update b/files/couch-doc-update
index df216db..903a661 100644
--- a/files/couch-doc-update
+++ b/files/couch-doc-update
@@ -116,14 +116,30 @@ def get_document(db, doc_id)
end
def update_document(db, doc, data)
+ attempt ||= 1
doc.reject! {|k,v| !["_id", "_rev"].include? k}
doc.merge! data
db.save_doc(doc)
+rescue RestClient::Exception => e
+ if e.response.code == 500
+ raise if attempt > 5
+ attempt += 1
+ sleep 10
+ retry
+ end
end
def create_document(db, doc_id, data)
+ attempt ||= 1
data["_id"] = doc_id
db.save_doc(data)
+rescue RestClient::Exception => e
+ if e.response.code == 500
+ raise if attempt > 5
+ attempt += 1
+ sleep 10
+ retry
+ end
end
def connection_string(database, host, netrc_file = nil)