Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-1298

Segfault when closing while async operations are happening



    • Bug
    • Resolution: Fixed
    • Major
    • 4.0.x
    • None
    • library
    • None
    • 1


      For instance, this will segfault because the AsyncBucket is connecting in the background...

      auth = PasswordAuthenticator(username="Administrator", password="password")
      c = Cluster("couchbase://localhost", ClusterOptions(authenticator=auth))
      await c.on_connect()
      b = c.bucket("default")
      # uncomment this, and no crash
      # await b.on_connect()
      await c.close()

      Of course, we can't prevent all racing, but lets think about how to make this better. First off, lets insure close() is being called when a Cluster is deleted, so users never need to call it.

      At that point, we can figure out if we want something which helps with this, since it is a misuse of the api, but not an obvious one. Some options:

      • c.bucket(...) could return an Awaitable, which makes this scenario not possible
      • we could think about holding weak references to the conn object in places we use it (bucket, collection, etc...). There's still a race here though, I believe...
      • we could find a way to chain the close off any existing operations (but that sounds difficult/complex, however maybe not?)
      • Something else.

      This ticket needs to address the close() not being necessary to call - that seems like the first level of defense. We can spawn a new ticket for any ancillary work (perhaps for later), when we decide we need it.


        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.



              jared.casey Jared Casey
              david.kelly David Kelly (Inactive)
              0 Vote for this issue
              2 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes