FileDriver is not support multiple process

Bug #1665897 reported by mengalong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tooz
Fix Released
High
zhangsong

Bug Description

RT

I try to use FileDriver in a machine.
I write a simple test code.
It's function is: get_coordinator via FileDriver -> join a group -> sleep 10 seconds -> coordinator.stop()

1. I execute the script, after join_group, it will sleep(10). We called this process P1.
2. During the P1 execute time.sleep(10), I re-execute the same script we called P2.

Then I find that: P2 will be blocked at join a group until the P1 finished
I think this is a bug.

Here is my test code:
==============================================================
import time
import tooz
import uuid

from tooz import coordination

driver_url = "file:///tmp/test_coor"
my_id = str(uuid.uuid4())
group_id = "test_group"

coordinator = coordination.get_coordinator(driver_url, my_id)
coordinator.start()

while True:
    try:
        join_req = coordinator.join_group(group_id)
        print("start to get the join result")
        join_req.get() ## It will be blocked at here
        print("join the group:%s" % group_id)
        break
    except tooz.coordination.MemberAlreadyExist:
        raise
    except tooz.coordination.GroupNotCreated:
        create_grp_req = coordinator.create_group(group_id)
        try:
            create_grp_req.get()
        except tooz.coordination.GroupAlreadyExist:
            pass
    except tooz.coordination.ToozError as err:
        print("join the group:%s failed for:%s" % (group_id, err))

print("start to sleep 10 secs")
time.sleep(10)

coordinator.stop()
=====================================================================

BTW: tooz version: 1.48.0

Revision history for this message
Julien Danjou (jdanjou) wrote :

Yes, looks like a bug in FileLock to me.

Changed in python-tooz:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Joshua Harlow (harlowja) wrote :

Ya, feels like a bug

zhangsong (zhangsong)
Changed in python-tooz:
assignee: nobody → zhangsong (zhangsong)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tooz (master)

Fix proposed to branch: master
Review: https://review.openstack.org/446310

Changed in python-tooz:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tooz (master)

Reviewed: https://review.openstack.org/446310
Committed: https://git.openstack.org/cgit/openstack/tooz/commit/?id=40e749598bbd504f018d56e6773d80eaff5a3624
Submitter: Jenkins
Branch: master

commit 40e749598bbd504f018d56e6773d80eaff5a3624
Author: zhangsong <email address hidden>
Date: Thu Mar 16 13:00:02 2017 +0800

    FileDriver:Support multiple processes

    The interprocess file-lock is not really released when user call
    FileLock.release() method. So the second process will be blocked
    when it try to acquire a lock which has been 'released' by the
    first process until the first process is exited. This lead to
    current filelock don't support multiple processes. This patch
    fixed this problem.

    Closes-Bug: #1665897
    Change-Id: I3d4331a400dd551fa97cada2d7af9415fda720da

Changed in python-tooz:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tooz 1.53.0

This issue was fixed in the openstack/tooz 1.53.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.