From patchwork Sat Aug 26 11:44:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zengganghui X-Patchwork-Id: 806115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xfbnG74z1z9t4g for ; Sat, 26 Aug 2017 21:45:21 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 53705258; Sat, 26 Aug 2017 11:45:17 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 91F242C for ; Sat, 26 Aug 2017 11:45:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5AD268A for ; Sat, 26 Aug 2017 11:45:14 +0000 (UTC) Received: from 172.30.72.58 (EHLO DGGEMS410-HUB.china.huawei.com) ([172.30.72.58]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFZ98466; Sat, 26 Aug 2017 19:45:01 +0800 (CST) Received: from localhost (10.177.241.172) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.301.0; Sat, 26 Aug 2017 19:44:59 +0800 From: ZengGanghui To: Date: Sat, 26 Aug 2017 19:44:53 +0800 Message-ID: <1503747893-16556-1-git-send-email-zengganghui@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.241.172] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.59A15F3D.0054, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 038efbfe80537f64ff06065731c19217 X-Spam-Status: No, score=-0.0 required=5.0 tests=RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] fix ovsdb-server memory growth issues when ovs-vsctl cmd stucking. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When rpc sends message failed with return EAGIN, it will try to send again unlimitly. Finally, the memory of ovsdb-server will grow infinitly. Signed-off-by: ZengGanghui --- lib/jsonrpc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index 2fae057..6506dc2 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -49,6 +49,9 @@ struct jsonrpc { struct ovs_list output; /* Contains "struct ofpbuf"s. */ size_t output_count; /* Number of elements in "output". */ size_t backlog; + + /* send retry times */ + int retries; }; /* Rate limit for error messages. */ @@ -127,10 +130,17 @@ jsonrpc_run(struct jsonrpc *rpc) ofpbuf_delete(buf); } } else { - if (retval != -EAGAIN) { - VLOG_WARN_RL(&rl, "%s: send error: %s", - rpc->name, ovs_strerror(-retval)); + if (retval != -EAGAIN || rpc->retries++ > 256) { + VLOG_WARN_RL(&rl, "%s: send error - %s: %s", + rpc->name, + retval != -EAGAIN ? "not again" : "over retries", + ovs_strerror(-retval)); jsonrpc_error(rpc, -retval); + } else { + VLOG_DBG_RL(&rl, "%s: send again: %s, retries %d", + rpc->name, + ovs_strerror(-retval), + rpc->retries); } break; } @@ -503,6 +513,7 @@ jsonrpc_cleanup(struct jsonrpc *rpc) ofpbuf_list_delete(&rpc->output); rpc->backlog = 0; rpc->output_count = 0; + rpc->retries = 0; } static struct jsonrpc_msg *