Segmentation fault: 11

Hi!

Not sure how to handle this… I upgraded to SDK 3.0.5 and since they i keep getting segmentation fault when using my application towards Couchbase 6.5

I can reduce the risk of this issue if i lower the number of threads that are connecting to Couchbase at the same time but more than 2 threads will cause the issue within a few minutes.

Any suggestions?

Oh by the way… I am currently running a Cluster pool where a thread can “borrow” a cluster to use and then return it. I also tried to use a new cluster connection for each thread but that didnt helt either.

//Micke

@micke Can you please share sample code to reproduce the problem?

Hi!

I have tried to reproduce the issue with some example code but i could not. Based on this my conclusion is that i might have got another issue at the same time when i upgraded to Couchbase SDK 3.x.
If i change my main program to create a new cluster connection for each Query the problem has disappeared (now i have another issue to solve). If i use my cluster pool i get the issues back.

conn_string = "couchbase://%s" % (url,)
c_options = ClusterTimeoutOptions(query_timeout=timedelta(seconds=180))
cluster = ClusterConnection.connect(conn_string, ClusterOptions(authenticator=PasswordAuthenticator(
                                                        username, password), timeout_options=c_options), lockmode=2)

my guess is that lockmode is not working the same as in SDK 2.X. It doesn’t matter if i add the lock mode in ClusterOptions either since it will be set to 1 no matter what.

In summary - the issue might be that lockmode is not working currently.

//Micke

You should pass in the lock mode as ClusterOptions(lockmode=LockMode.WAIT): https://github.com/couchbase/couchbase-python-client/blob/b1f3a9d69071831a37329a8c156cd8cb141f584a/couchbase/cluster.py#L330

Apologies for this not being documented better - but it’s a fairly low-level, Python-client-specific feature. The type hint specifies the usage of the LockMode enum, so if you use a Type Hinting compliant editor such as PyCharm, PyDev, or even JEDI for Emacs with Flycheck, you should get autocomplete suggestions and validation, prompting you to use the said enum. I’ll raise a JIRA to add the info to the ClusterOptions constructor docstring.

Hope that helps,

Ellis

Hi!

I have tried that too but that doesnt work if i check the code for ClusterOptions…
Short example with prints (if cluster.lockmode shows the lockmode that was set)

def connect(alternative):
    try:
        conn_string = "couchbase://%s" % (address,)

        c_options = ClusterTimeoutOptions(query_timeout=timedelta(seconds=180))

        if alternative == 1: # Set LockMode.WAIT in ClusterOptions
            connection = Cluster.connect(conn_string,
                                     ClusterOptions(authenticator=PasswordAuthenticator(username, password),
                                                    timeout_options=c_options, lockmode=LockMode.WAIT))
        elif alternative == 2: # Set LockMode.WAIT in connect
            connection = Cluster.connect(conn_string,
                                         ClusterOptions(authenticator=PasswordAuthenticator(username, password),
                                                        timeout_options=c_options), lockmode=LockMode.WAIT)
        else: # Dont set LockMode
            connection = Cluster.connect(conn_string,
                                         ClusterOptions(authenticator=PasswordAuthenticator(username, password),
                                                        timeout_options=c_options))

        print("LockMode: {}".format(connection.lockmode))
        return connection

    except CouchbaseException as e:
        print("CouchbaseException: %s" % (e.args,))


cluster = connect(1)
cluster.disconnect()
cluster = connect(2)
cluster.disconnect()
cluster = connect(3)
cluster.disconnect()

The print will then be:
LockMode: 1
LockMode: 2
LockMode: 1

Based on this i use the old way - but right now it doesnt matter since i create a new cluster object for each connect.

//MIcke