This patch updates the CACHEDB_COUCHBASE module. It adds better error reporting and handling as well as automatic reconnects for certain error codes.
Removed calls to lcb_get_last_error. Since we have callbacks set this is unnecessary and we can go off the last_error variable.
Moved error log messages to the callback only, to reduce noise in the logs. (Perhaps debug messages would be appropriate in the get, set, remove, and arithmetic methods?)
For both the get and remove methods I have made changes so that Non-existent keys return -1 and all other failures return -2. Since couchbase can be used as a primary data-store it is
very important to distinguish between no data and other failures at the script level, as the data may not be available elsewhere. This involved a change to the cachedb_fetch(), cachedb_counter_fetch(), and cachedb_remove() methods in cachedb.c to pass through the return code of the underlying drivers method. Compatibility with the other cachedb_* modules should be verified.
The libcouchbase library does a pretty good job of handling reconnects itself, there are however a few scenarios where it will get into a state where it will not reconnect. When one of these errors are detected we created a new handle and destroy the old one. This list of errors may need review.
Because of this we also support starting opensips without successfully connecting to couchbase, and are able to connect to it later once the service becomes available. We will still fail to start on certain connection errors that are deemed fatal. Again this list of errors may need review.
I updated the documentation to include an example of multiple hosts in the connection string. I have tested the following works:
If 192.168.122.192 is not available it will still connect to the cluster via 192.168.122.77.
I wrote this patch against 1.9, but I think it should apply against trunk just fine. It would be nice if this could be applied to 1.9 as well, however the changes for return codes may pose an issue there.
Happy to answer any questions!
Log in to post a comment.