From patchwork Fri May 1 19:13:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Michelson X-Patchwork-Id: 1281433 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DDwJTiFt; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49DMNR208Yz9sSk for ; Sat, 2 May 2020 05:13:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 24B69884BF; Fri, 1 May 2020 19:13:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ov-IXNMVUlnT; Fri, 1 May 2020 19:13:23 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 541CE884FC; Fri, 1 May 2020 19:13:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2D41CC0864; Fri, 1 May 2020 19:13:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id B11C6C016F for ; Fri, 1 May 2020 19:13:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 8A16625A5E for ; Fri, 1 May 2020 19:13:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kBmDfcpLDDYP for ; Fri, 1 May 2020 19:13:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by silver.osuosl.org (Postfix) with ESMTPS id 4189925931 for ; Fri, 1 May 2020 19:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588360396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Dl2CuRMCjzGi4bRbGqjLBY8gEbIjJI6M7W2hFtciw0g=; b=DDwJTiFtyOej6piDOp5+4ZVPFGV12kBdJpwSL2dFjVMfI+dwco90NQb9r1W/wqgiHexwQi ECcev7IXBLQKU/8rLwjzB5vvXUFUsff1R5rS7rRsH8oPGMuERRCSNybFtdgayWaDKEsde0 9VqpAFQR6v0vTyWwLOtVddlMD71eois= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-qaXkwhMGNDiJCUJcz0b-JA-1; Fri, 01 May 2020 15:13:15 -0400 X-MC-Unique: qaXkwhMGNDiJCUJcz0b-JA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5757A100CCC2 for ; Fri, 1 May 2020 19:13:10 +0000 (UTC) Received: from monae.redhat.com (ovpn-116-51.rdu2.redhat.com [10.10.116.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0C286109E for ; Fri, 1 May 2020 19:13:09 +0000 (UTC) From: Mark Michelson To: dev@openvswitch.org Date: Fri, 1 May 2020 15:13:08 -0400 Message-Id: <20200501191308.94486-1-mmichels@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH] ovsdb-idl: Add function to reset min_index. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" If an administrator removes all of the databases in a cluster from disk, then ovsdb IDL clients will have a problem. The databases will all reset their stored indexes to 0, so The IDL client's min_index will be higher than the indexes of all databases in the cluster. This results in the client constantly connecting to databases, detecting the data as "stale", and then attempting to connect to another. This function provides a way to reset the IDL to an initial state with min_index of 0. This way, the client will not wrongly detect the database data as stale and will recover properly. Notice that this function is not actually used anywhere in this patch. This will be used by OVN, though, since OVN is the primary user of clustered OVSDB. Signed-off-by: Mark Michelson Acked-by: Han Zhou --- lib/ovsdb-idl.c | 10 ++++++++++ lib/ovsdb-idl.h | 1 + 2 files changed, 11 insertions(+) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 1535ad7b5..9c66a6d4f 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -553,6 +553,16 @@ ovsdb_idl_set_shuffle_remotes(struct ovsdb_idl *idl, bool shuffle) idl->shuffle_remotes = shuffle; } +/* Reset min_index to 0. This prevents a situation where the client + * thinks all databases have stale data, when they actually have all + * been destroyed and rebuilt from scratch. + */ +void +ovsdb_idl_reset_min_index(struct ovsdb_idl *idl) +{ + idl->min_index = 0; +} + static void ovsdb_idl_db_destroy(struct ovsdb_idl_db *db) { diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h index 9f12ce320..c56cd19b1 100644 --- a/lib/ovsdb-idl.h +++ b/lib/ovsdb-idl.h @@ -64,6 +64,7 @@ struct ovsdb_idl *ovsdb_idl_create_unconnected( const struct ovsdb_idl_class *, bool monitor_everything_by_default); void ovsdb_idl_set_remote(struct ovsdb_idl *, const char *, bool); void ovsdb_idl_set_shuffle_remotes(struct ovsdb_idl *, bool); +void ovsdb_idl_reset_min_index(struct ovsdb_idl *); void ovsdb_idl_destroy(struct ovsdb_idl *); void ovsdb_idl_set_leader_only(struct ovsdb_idl *, bool leader_only);