From patchwork Sun Dec 13 14:16:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 556183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 5315A140311 for ; Mon, 14 Dec 2015 01:17:08 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 9AA8510A11; Sun, 13 Dec 2015 06:17:06 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 9D17D10A10 for ; Sun, 13 Dec 2015 06:17:05 -0800 (PST) Received: from bar2.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id AE7A44200CC for ; Sun, 13 Dec 2015 07:17:04 -0700 (MST) X-ASG-Debug-ID: 1450016222-03dc530f735b22c0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar2.cudamail.com with ESMTP id j4Mime9SyGPintA4 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 13 Dec 2015 07:17:02 -0700 (MST) X-Barracuda-Envelope-From: nusiddiq@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 13 Dec 2015 14:17:02 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 86FC2461E2 for ; Sun, 13 Dec 2015 14:17:00 +0000 (UTC) Received: from nusiddiq.blr.redhat.com (ovpn-113-80.phx2.redhat.com [10.3.113.80]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBDEGuNx019365 for ; Sun, 13 Dec 2015 09:16:58 -0500 X-CudaMail-Envelope-Sender: nusiddiq@redhat.com From: Numan Siddique X-CudaMail-MID: CM-E2-1212007905 X-CudaMail-DTE: 121315 X-CudaMail-Originating-IP: 209.132.183.28 To: dev@openvswitch.org X-ASG-Orig-Subj: [##CM-E2-1212007905##][PATCH] ovn-northd: Recalculate db mappings if the txn returns TXN_ERROR Organization: Red Hat Message-ID: <566D7DD4.5070708@redhat.com> Date: Sun, 13 Dec 2015 19:46:52 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-GBUdb-Analysis: 0, 209.132.183.28, Ugly c=0.318533 p=-0.0909091 Source Normal X-MessageSniffer-Rules: 0-0-0-6357-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1450016222 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 3.10 X-Barracuda-Spam-Status: No, SCORE=3.10 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, BSF_SC7_SA_HREF_FROM_MISMATCH_TEXT_URIx1_HL, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.25219 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 2.50 BSF_SC7_SA_HREF_FROM_MISMATCH_TEXT_URIx1_HL Custom Rule HREF_FROM_MISMATCH_TEXT_URIx1_HL Subject: [ovs-dev] [PATCH] ovn-northd: Recalculate db mappings if the txn returns TXN_ERROR X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" Fixes the issue Reported-at: http://openvswitch.org/pipermail/discuss/2015-November/019443.html Signed-off-by: Numan Siddique --- lib/ovsdb-idl.c | 1 + lib/ovsdb-idl.h | 1 + ovn/northd/ovn-northd.c | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 0d02ae8..2e536c9 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -3209,6 +3209,7 @@ ovsdb_idl_loop_commit_and_wait(struct ovsdb_idl_loop *loop) ovsdb_idl_txn_destroy(txn); loop->committing_txn = NULL; } + loop->last_commit_status = status; } ovsdb_idl_wait(loop->idl); diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h index 4c66ae0..5f7f2fc 100644 --- a/lib/ovsdb-idl.h +++ b/lib/ovsdb-idl.h @@ -266,6 +266,7 @@ struct ovsdb_idl_loop { unsigned int precommit_seqno; struct ovsdb_idl_txn *open_txn; + enum ovsdb_idl_txn_status last_commit_status; }; #define OVSDB_IDL_LOOP_INITIALIZER(IDL) { .idl = (IDL) } diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 270b116..be4d6a8 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -1912,6 +1912,8 @@ main(int argc, char *argv[]) /* Main loop. */ exiting = false; + bool ovnnb_changes_pending = false; + bool ovnsb_changes_pending = false; while (!exiting) { struct northd_context ctx = { .ovnnb_idl = ovnnb_idl_loop.idl, @@ -1922,11 +1924,28 @@ main(int argc, char *argv[]) if (ovnnb_seqno != ovsdb_idl_get_seqno(ctx.ovnnb_idl)) { ovnnb_seqno = ovsdb_idl_get_seqno(ctx.ovnnb_idl); - ovnnb_db_run(&ctx); + ovnnb_changes_pending = true; } if (ovnsb_seqno != ovsdb_idl_get_seqno(ctx.ovnsb_idl)) { ovnsb_seqno = ovsdb_idl_get_seqno(ctx.ovnsb_idl); + ovnsb_changes_pending = true; + } + + /* + * We need to recalculate the mappings to the OVN-sb db + * - If the OVN-nb db has changed or + * - If the previous update to the OVN-sb is not yet completed. + */ + if (ovnnb_changes_pending || + ovnsb_idl_loop.last_commit_status == TXN_ERROR) { + ovnnb_db_run(&ctx); + ovnnb_changes_pending = false; + } + + if (ovnsb_changes_pending || + ovnnb_idl_loop.last_commit_status == TXN_ERROR) { ovnsb_db_run(&ctx); + ovnsb_changes_pending = false; } unixctl_server_run(unixctl);