Couchbase C lib

In our app we do use protobuf and couchbase C lib . While compiling protobuf throws “assert” compilation error Since couchbase lib contains assert.h . How can we override this conflict ?
Kindly advice

Hi, not a C expert but @mnunberg can probably help you.

This should only happen if you have include/libcouchbase itself in your include path; otherwise #include <assert.h> would include the normal C assert.h header.

Can you paste the error message you’ve been getting?

Getting undefined reference to lcb_create . Similar to Cannot compile C devguide-examples: connecting.c:8: undefined reference to `lcb_strerror' etc

We are using ant build script with cc. Exactly where we should include ldflags=-lcouchbase

resolved it can be closed . Regarding client library , how can we get the response from callback to main function

You would use a cookie pointer. This example is in C++ since it’s shorter, but the same can be applied in C

class Result {
  public:
  std::string key;
  std::string value;
  lcb_error_t rc;
}

static void
get_callback(lcb_t, int, const lcb_RESPGET *rg)
{
  Result *uresp = (Result *)rg->cookie;
  if ((uresp->rc = rg->rc) == LCB_SUCCESS) {
    uresp->key.assign((const char *)rg->key, rg->nkey);
    uresp->value.assign((const char *)rg->value, rg->nvalue);
  }

}

// set the callback somewhere
lcb_install_callback3(instance, LCB_CALLBACK_GET, (lcb_RESPCALLBACK)get_callback);

// in your scheduling code
lcb_CMDGET gcmd = { 0 };
LCB_CMD_SET_KEY(&gcmd, "some-key", strlen("some-key"));
Result r;
lcb_error_t rc = lcb_get3(instance, &r, &gcmd);
lcb_wait(instance);

with concurreny 1000 and request 3000 , after 1000 request getting client time exceeded error .
Even tried changing the time out using
LCB_U32 newval = 3000000
lcb_cntl(instance,LCB_CNTL_SET,LCB_CNTL_OP_TIMEOUT, &newval) ;
still it fails .

I’m not sure what is meant by “concurrency 1000” and “request 3000”, but you might be sending too much data over the network; your timeout may need to be longer than 3 seconds.

Please refer to the documentation for how to enable logging for more details: http://developer.couchbase.com/documentation/server/4.0/sdks/c-2.4/logging.html

Increased the log level and below is the error

6114ms [I501] {15628} [DEBUG] (lcbio_mgr - L:383) <10.223.19.82:11210> (HE=0x7fb3300171c0) Creating new connection because none are available in the pool
16114ms [I501] {15628} [DEBUG] (lcbio_mgr - L:301) <10.223.19.82:11210> (HE=0x7fb3300171c0) Starting connection on I=0x7fb330017660
16114ms [I501] {15628} [INFO] (connection - L:423) <10.223.19.82:11210> (SOCK=0x7fb330017730) Starting. Timeout=2000000us
16114ms [I501] {15628} [TRACE] (connection - L:241) <10.223.19.82:11210> (SOCK=0x7fb330017730) Got event handler for new connection
16114ms [I501] {15628} [TRACE] (connection - L:288) <10.223.19.82:11210> (SOCK=0x7fb330017730) Scheduling asynchronous watch for socket.
16114ms [I501] {15628} [TRACE] (connection - L:241) <10.223.19.82:11210> (SOCK=0x7fb330017730) Got event handler for new connection
16114ms [I501] {15628} [INFO] (connection - L:99) <10.223.19.82:11210> (SOCK=0x7fb330017730) Connected
16114ms [I501] {15628} [DEBUG] (lcbio_mgr - L:255) <10.223.19.82:11210> (HE=0x7fb3300171c0) Received result for I=0x7fb330017660,C=0x7fb330017730; E=0x0
16114ms [I501] {15628} [DEBUG] (lcbio_mgr - L:206) <10.223.19.82:11210> (HE=0x7fb3300171c0) Assigning R=0x7fb330015e00 SOCKET=0x7fb330017730
16114ms [I501] {15628} [DEBUG] (ioctx - L:84) <10.223.19.82:11210> (CTX=0x7fb330028860,unknown) Pairing with SOCK=0x7fb330017730
18117ms [I501] {15628} [ERROR] (negotiation - L:162) <10.223.19.82:11210> (SASLREQ=0x7fb33001acb0) Error: 0x17, Negotiation timed out
18117ms [I501] {15628} [ERROR] (cccp - L:130) NOHOST:NOPORT Got I/O Error=0x17
18117ms [I501] {15628} [INFO] (confmon - L:196) Provider ‘CCCP’ failed
18117ms [I501] {15628} [DEBUG] (ioctx - L:134) <10.223.19.82:11210> (CTX=0x7fb330028860,sasl) Destroying. PND=0,ENT=0,SORC=1
18217ms [I501] {15628} [TRACE] (confmon - L:252) Current provider is HTTP
18217ms [I501] {15628} [TRACE] (htconfig - L:395) Starting HTTP Configuration Provider 0x7fb3300033c0
18217ms [I501] {15628} [INFO] (connection - L:423) <10.223.19.82:8091> (SOCK=0x7fb330017730) Starting. Timeout=2000000us
18217ms [I501] {15628} [TRACE] (connection - L:241) <10.223.19.82:8091> (SOCK=0x7fb330017730) Got event handler for new connection
18218ms [I501] {15628} [TRACE] (connection - L:288) <10.223.19.82:8091> (SOCK=0x7fb330017730) Scheduling asynchronous watch for socket.
18218ms [I501] {15628} [TRACE] (connection - L:241) <10.223.19.82:8091> (SOCK=0x7fb330017730) Got event handler for new connection
18218ms [I501] {15628} [INFO] (connection - L:99) <10.223.19.82:8091> (SOCK=0x7fb330017730) Connected
18218ms [I501] {15628} [DEBUG] (htconfig - L:346) Successfuly connected to REST API 10.223.19.82:8091
18218ms [I501] {15628} [DEBUG] (ioctx - L:84) <10.223.19.82:8091> (CTX=0x7fb330017e80,unknown) Pairing with SOCK=0x7fb330017730
20220ms [I501] {15628} [ERROR] (htconfig - L:375) <10.223.19.82:8091> HTTP Provider timed out waiting for I/O
20220ms [I501] {15628} [DEBUG] (ioctx - L:134) <10.223.19.82:8091> (CTX=0x7fb330017e80,bc_http) Destroying. PND=0,ENT=0,SORC=1
20221ms [I501] {15628} [INFO] (confmon - L:196) Provider ‘HTTP’ failed
20221ms [I501] {15628} [TRACE] (confmon - L:213) Maximum provider reached. Resetting index
20221ms [I501] {15628} [ERROR] (bootstrap - L:93) Failed to bootstrap client=0x7fb3300164f0. Code=0xa, Message=No more bootstrap providers remain

1.couchbase is running in single node 8GB RAM 4 core processor
2.Is there any max connection limitation .
3.in connection string should we refer hostname/ip .

  //Create Instance

  cropts.version = 3;
  cropts.v.v3.connstr = "couchbase://ip/default";
  err = lcb_create(&instance, &cropts);
  if (err != LCB_SUCCESS) {
                 //exit
  }

  //change time out
  lcb_U32 newval = 10000000; // Set to 4 seconds
  lcb_cntl(instance, LCB_CNTL_SET, LCB_CNTL_OP_TIMEOUT, &newval);


  // connecting
  lcb_connect(instance);
  lcb_wait(instance);
  if ( (err = lcb_get_bootstrap_status(instance)) != LCB_SUCCESS ) {
                  //exit
  }

  // installing callbacks
  lcb_set_get_callback(instance, get_callback);


  // scheduling operations
  lcb_get_cmd_t gcmd ;
  const lcb_get_cmd_t *gcmdlist = &gcmd;
  gcmd.v.v0.key = key;
  gcmd.v.v0.nkey = key.length();
  err = lcb_get(instance, &mr, 1, &gcmdlist);
  if (err != LCB_SUCCESS) {
   //exit
	  }

  lcb_wait(instance); // get_callback is invoked here

To modify the bootstrap timeout you need to use http://docs.couchbase.com/sdk-api/couchbase-c-client-2.5.6/group__lcb-cntl-settings.html#gaef4f0191aaf344c3f9b859e30537a71d (LCB_CNTL_CONFIGURATION_TIMEOUT). The other timeout is only for individual operations.

It would seem that you have netwoek connectivity issues between client and server. Are you able to contact any of the ports mentioned in the log manually?

Even changing the time out didnt help.My firewall is stopped .
9569ms [I500] {18719} [TRACE] (confmon - L:252) Current provider is CCCP
9569ms [I500] {18719} [DEBUG] (lcbio_mgr - L:383) <10.223.19.82:11210> (HE=0x7fcb98017660) Creating new connection because none are available in the pool
9569ms [I500] {18719} [DEBUG] (lcbio_mgr - L:301) <10.223.19.82:11210> (HE=0x7fcb98017660) Starting connection on I=0x7fcb98024080
9569ms [I500] {18719} [INFO] (connection - L:423) <10.223.19.82:11210> (SOCK=0x7fcb98011a40) Starting. Timeout=9000000us
9569ms [I500] {18719} [TRACE] (connection - L:241) <10.223.19.82:11210> (SOCK=0x7fcb98011a40) Got event handler for new connection
9569ms [I500] {18719} [TRACE] (connection - L:288) <10.223.19.82:11210> (SOCK=0x7fcb98011a40) Scheduling asynchronous watch for socket.
9569ms [I500] {18719} [TRACE] (connection - L:241) <10.223.19.82:11210> (SOCK=0x7fcb98011a40) Got event handler for new connection
9569ms [I500] {18719} [INFO] (connection - L:99) <10.223.19.82:11210> (SOCK=0x7fcb98011a40) Connected
9569ms [I500] {18719} [DEBUG] (lcbio_mgr - L:255) <10.223.19.82:11210> (HE=0x7fcb98017660) Received result for I=0x7fcb98024080,C=0x7fcb98011a40; E=0x0
9569ms [I500] {18719} [DEBUG] (lcbio_mgr - L:206) <10.223.19.82:11210> (HE=0x7fcb98017660) Assigning R=0x7fcb98006360 SOCKET=0x7fcb98011a40
9569ms [I500] {18719} [DEBUG] (ioctx - L:84) <10.223.19.82:11210> (CTX=0x7fcb98018230,unknown) Pairing with SOCK=0x7fcb98011a40
14568ms [I500] {18719} [ERROR] (bootstrap - L:93) Failed to bootstrap client=0x7fcb98029660. Code=0x17, Message=Failed to bootstrap in time
[vagrant@spoc-dev spocBuild]$ telnet 10.223.19.82 11210
Trying 10.223.19.82…
Connected to 10.223.19.82.
Escape character is ‘^]’.

How many client instances do you have? how often are you connecting to the cluster? your logs would suggest that this is the 500th lcb_t being created.

You should keep a single lcb_t around for each bucket.