Project

General

Profile

Actions

Bug #10567

closed

Python Ioctx should retain a reference to the cluster object

Added by Kim Vandry over 9 years ago. Updated about 9 years ago.

Status:
Resolved
Priority:
Urgent
Assignee:
-
Category:
librados
Target version:
-
% Done:

0%

Source:
other
Tags:
Backport:
Regression:
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

The following Python script segfaults:

import rados

def make_ioctx():
    cluster = rados.Rados(conffile='/etc/ceph/ceph.conf')
    cluster.connect()
    return cluster.open_ioctx("default")

make_ioctx().stat("foobar")

This is because the cluster object is destroyed when the "cluster" local variable goes out of scope, even though the ioctx still needs it.

Python programmers will expect that the cluster object will not be destroyed until the last reference to it is removed. We expect that if the just-created ioctx requires a reference to the cluster object in order to function then it will retain one.

The failure is because the reference to the cluster object exists only at the C/C++ level, where Python cannot track it.

Suggested fix:
  • change Rados.ioctx() to pass a reference to itself to the Ioctx constructor
  • have Ioctx.__init__() stash a reference to the cluster object using self.cluster = cluster
  • have Ioctx.close() remove the reference using del self.cluster or self.cluster = None

Related issues 1 (0 open1 closed)

Related to Ceph - Bug #8797: "ceph status" do not exit with python_2.7.8ResolvedDan Mick07/09/2014

Actions
Actions #1

Updated by Dan Mick about 9 years ago

  • Status changed from New to 12
  • Priority changed from Normal to Urgent
Actions #2

Updated by Kefu Chai about 9 years ago

  • Status changed from 12 to Resolved

as a side effect of the fix for #8797. we do not have Rados.__del__() anymore. so i consider it as resolved.

Actions

Also available in: Atom PDF