Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1B5A5200B27 for ; Tue, 7 Jun 2016 13:05:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1A11B160A61; Tue, 7 Jun 2016 11:05:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0BD0C160A35 for ; Tue, 7 Jun 2016 13:05:08 +0200 (CEST) Received: (qmail 65354 invoked by uid 500); 7 Jun 2016 11:05:06 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 64428 invoked by uid 99); 7 Jun 2016 11:05:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2016 11:05:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BC830E03A9; Tue, 7 Jun 2016 11:05:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Date: Tue, 07 Jun 2016 11:05:28 -0000 Message-Id: <38c38ab187504f67b3d428f1695e2bcb@git.apache.org> In-Reply-To: <05a811a245ff4d31adf398f97210b371@git.apache.org> References: <05a811a245ff4d31adf398f97210b371@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [24/44] couch-replicator commit: updated refs/heads/63012-defensive to 1afa5ea archived-at: Tue, 07 Jun 2016 11:05:10 -0000 Handle error in replication documents Retry on <<"error">> state. Those are documents updated by the older replicator code. Some of those errors were transient. Introduce <<"failed">> state for documents which fail to parse as valid replicator #rep{} records and can't even be submitted as jobs to job scheduler. On this state, don't attempt to start replication. Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/0be18f75 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/0be18f75 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/0be18f75 Branch: refs/heads/63012-defensive Commit: 0be18f75af9cf578007c57ccb06cb9316436ef68 Parents: a309e8d Author: Nick Vatamaniuc Authored: Thu Jun 2 15:28:04 2016 -0400 Committer: Nick Vatamaniuc Committed: Thu Jun 2 15:28:04 2016 -0400 ---------------------------------------------------------------------- src/couch_replicator_doc_processor.erl | 10 +++++++++- src/couch_replicator_docs.erl | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/0be18f75/src/couch_replicator_doc_processor.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator_doc_processor.erl b/src/couch_replicator_doc_processor.erl index ddaa2b0..0de88d9 100644 --- a/src/couch_replicator_doc_processor.erl +++ b/src/couch_replicator_doc_processor.erl @@ -68,7 +68,15 @@ process_update(DbName, {Change}) -> <<"triggered">> -> maybe_start_replication(DbName, DocId, JsonRepDoc); <<"completed">> -> - couch_log:notice("Replication '~s' marked as completed", [DocId]) + couch_log:notice("Replication '~s' marked as completed", [DocId]); + <<"error">> -> + % Handle replications started from older versions of replicator + % which wrote transient errors to replication docs + maybe_start_replication(DbName, DocId, JsonRepDoc); + <<"failed">> -> + Reason = get_json_value(<<"_replication_state_reason">>, RepProps), + Msg = "Replication '~s' marked as failed with reason '~s'", + couch_log:warning(Msg, [DocId, Reason]) end; {Owner, false} -> couch_log:notice("Not starting '~s' as owner is ~s.", [DocId, Owner]) http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/0be18f75/src/couch_replicator_docs.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator_docs.erl b/src/couch_replicator_docs.erl index 6c71f66..e9128df 100644 --- a/src/couch_replicator_docs.erl +++ b/src/couch_replicator_docs.erl @@ -76,7 +76,7 @@ update_doc_process_error(DbName, DocId, Error) -> end, couch_log:error("Error processing replication doc `~s`: ~s", [DocId, Reason]), update_rep_doc(DbName, DocId, [ - {<<"_replication_state">>, <<"error">>}, + {<<"_replication_state">>, <<"failed">>}, {<<"_replication_state_reason">>, Reason}]).