Return-Path: Delivered-To: apmail-hadoop-zookeeper-commits-archive@minotaur.apache.org Received: (qmail 53329 invoked from network); 5 May 2010 21:53:55 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 May 2010 21:53:55 -0000 Received: (qmail 43157 invoked by uid 500); 5 May 2010 21:53:55 -0000 Delivered-To: apmail-hadoop-zookeeper-commits-archive@hadoop.apache.org Received: (qmail 43118 invoked by uid 500); 5 May 2010 21:53:55 -0000 Mailing-List: contact zookeeper-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: zookeeper-dev@ Delivered-To: mailing list zookeeper-commits@hadoop.apache.org Received: (qmail 43110 invoked by uid 99); 5 May 2010 21:53:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 May 2010 21:53:55 +0000 X-ASF-Spam-Status: No, hits=-1433.8 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 May 2010 21:53:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8EC1923888EA; Wed, 5 May 2010 21:53:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r941510 - in /hadoop/zookeeper/trunk: CHANGES.txt src/contrib/zkpython/src/c/zookeeper.c src/contrib/zkpython/src/test/acl_test.py src/contrib/zkpython/src/test/close_deadlock_test.py Date: Wed, 05 May 2010 21:53:04 -0000 To: zookeeper-commits@hadoop.apache.org From: phunt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100505215304.8EC1923888EA@eris.apache.org> Author: phunt Date: Wed May 5 21:53:04 2010 New Revision: 941510 URL: http://svn.apache.org/viewvc?rev=941510&view=rev Log: ZOOKEEPER-763. Deadlock on close w/ zkpython / c client Added: hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/close_deadlock_test.py Modified: hadoop/zookeeper/trunk/CHANGES.txt hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/acl_test.py Modified: hadoop/zookeeper/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=941510&r1=941509&r2=941510&view=diff ============================================================================== --- hadoop/zookeeper/trunk/CHANGES.txt (original) +++ hadoop/zookeeper/trunk/CHANGES.txt Wed May 5 21:53:04 2010 @@ -49,6 +49,9 @@ BUGFIXES: ZOOKEEPER-764. Observer elected leader due to inconsistent voting view (henry via mahadev) + ZOOKEEPER-763. Deadlock on close w/ zkpython / c client + (henry via phunt) + IMPROVEMENTS: ZOOKEEPER-724. Improve junit test integration - log harness information (phunt via mahadev) Modified: hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c?rev=941510&r1=941509&r2=941510&view=diff ============================================================================== --- hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c (original) +++ hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c Wed May 5 21:53:04 2010 @@ -1258,12 +1258,15 @@ PyObject *pyzoo_set_acl(PyObject *self, /* Closes a connection, returns integer error code */ PyObject *pyzoo_close(PyObject *self, PyObject *args) { - int zkhid; + int zkhid, ret; if (!PyArg_ParseTuple(args, "i", &zkhid)) { return NULL; } CHECK_ZHANDLE(zkhid); - int ret = zookeeper_close(zhandles[zkhid]); + zhandle_t *handle = zhandles[zkhid]; + Py_BEGIN_ALLOW_THREADS + ret = zookeeper_close(handle); + Py_END_ALLOW_THREADS zhandles[zkhid] = NULL; // The zk C client frees the zhandle return Py_BuildValue("i", ret); } Modified: hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/acl_test.py URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/acl_test.py?rev=941510&r1=941509&r2=941510&view=diff ============================================================================== --- hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/acl_test.py (original) +++ hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/acl_test.py Wed May 5 21:53:04 2010 @@ -103,7 +103,7 @@ class ACLTest(zktestbase.TestBase): "/zk-python-aclverifytest", "", invalid_acl, - zookeeper.EPHEMERAL)) + zookeeper.EPHEMERAL) if __name__ == '__main__': unittest.main() Added: hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/close_deadlock_test.py URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/close_deadlock_test.py?rev=941510&view=auto ============================================================================== --- hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/close_deadlock_test.py (added) +++ hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/close_deadlock_test.py Wed May 5 21:53:04 2010 @@ -0,0 +1,50 @@ +#!/usr/bin/python +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import zookeeper, zktestbase, unittest, threading +import time + + +class CloseDeadlockTest(zktestbase.TestBase): + """ + This tests for the issue found in + https://issues.apache.org/jira/browse/ZOOKEEPER-763 + + zookeeper.close blocks on waiting for all completions to + finish. Previously it was doing so while holding teh GIL, stopping + any completions from actually continuing. + + This test is a failure if it does not exit within a few seconds. + """ + def deadlock(): + cv = threading.Condition() + + def callback(*args): + cv.acquire() + cv.notifyAll() + cv.release() + time.sleep(1) + + cv.acquire() + zookeeper.aget(handle, "/", None, callback) + cv.wait() + zookeeper.close(handle) + + +if __name__ == '__main__': + unittest.main()