Bug #14089
Updated by Josh Durgin over 8 years ago
My ceph version is 0.94.When i use the Multithreading run rbd api like below. The librbd will core dump.Why the librbd api is not thread safe? <pre> import rados import rbd import hashlib import datetime import threading RADOS_NAME = 'client.admin' RBDTIMEOUT = 20 num=0 def md5(raw): import hashlib hasher = hashlib.md5() hasher.update(raw) return hasher.hexdigest() mu = threading.Lock() mu1 = threading.Lock() class RBDHandle(): def __init__(self, clustername="ceph"): self._clustername = clustername def getmd5info(self, ivalue): hasher = hashlib.md5() hasher.update(str(ivalue)) return hasher.hexdigest() def testconnect(self): try: cluster_handle = rados.Rados(name=RADOS_NAME, clustername=self._clustername, conffile='') cluster_handle.connect(timeout=RBDTIMEOUT) except: print "it is error" finally: cluster_handle.shutdown() if mu1.acquire(): global num num = num + 1 mu1.release() print num def test_fuc(): crb = RBDHandle() data={} threads=[] for i in range(1,10): print "it is begin" t=threading.Thread(target= crb.testconnect) threads.append(t) for t in threads: t.setDaemon(True) t.start() t.join() if __name__ == "__main__": while True: global num num = 0 test_fuc() if num != 9: break print "it is over" </pre>