Bug 711525

Summary: Connection.establish locks up when using subprocess
Product: Red Hat Enterprise MRG Reporter: Nick Capito <ncapito>
Component: python-qpidAssignee: messaging-bugs <messaging-bugs>
Status: NEW --- QA Contact: MRG Quality Engineering <mrgqe-bugs>
Severity: high Docs Contact:
Priority: medium    
Version: 1.3CC: jross
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Test script to stimulate the issue none

Description Nick Capito 2011-06-07 18:03:56 UTC
Created attachment 503546 [details]
Test script to stimulate the issue

If we call the Connection.establish("any broker"), and then spawn a process that has a Connection.establish("any broker") the Connection.establish will never return.


I have provided a test script to illustrate the problem.  Its a simple script it basically does the following:


1.  Create a connection and receiver
2.  Spawn the Process class
3.  The process class spawns 2 threads which call Connection.establish

You will see the Connection.establish never returns.


---

Notes from messing around with this I think the issue is relating to the drives _buf attribute getting cleared/currupted.  I can see headers getting packed, and then randomly getting cleared by some extenernal process.

Comment 1 Nick Capito 2011-06-07 18:45:20 UTC
The issue might be with the Selector class, it basically is reusing the same selector, but when we create the child process this is no longer valid.


Potential fix:

class Selector:

  lock = Lock()
  DEFAULT = {}

  @staticmethod
  def default():
    Selector.lock.acquire()
    try:
      process_id = os.getpid()
      if(not Selector.DEFAULT.has_key(group)):
        sel = Selector()
        atexit.register(sel.stop)
        sel.start()
        Selector.DEFAULT[process_id] = sel
      return Selector.DEFAULT[process_id]
    finally:
      Selector.lock.release()

Comment 2 Nick Capito 2011-06-07 18:51:04 UTC
There is a typo in the abox the


  if(not Selector.DEFAULT.has_key(group)):

should read 

  if(not Selector.DEFAULT.has_key(process_id)):