Description
How to reproduce:
1) Attach second node to a Couchbase claster, start rebalance process and in that time call lcb_get function many times. As a result application go down (assert in 0).
assert(ringbuffer_read(&src->pending_cookies, &ct, sizeof(ct)) == sizeof(ct));
src->pending_cookies->nbytes == 0 in that case, so ringbuffer_read return 0 so assert is 0
and application is over.
We think, that nbytes == 0 is a common situation, than src->connected == 0 and this situation must not interpretated as error.
Below you can find additional information
Stack:
#0 0xc000000000211ab0:0 in _lwp_kill+0x30 () from /lib/hpux64/libpthread.so.1
#1 0xc000000000178810:0 in pthread_kill ()
at /ux/core/libs/threadslibs/src/common/pthreads/signal.c:207
#2 0xc0000000003f8140:0 in raise ()
at ../../../../../core/libs/libc/shared_em_64_perf/../core/gen/raise.c:33
#3 0xc000000000508c50:0 in abort ()
at ../../../../../core/libs/libc/shared_em_64_perf/../core/gen/abort_em.c:84
#4 0xc0000000003c3f90:0 in _assert ()
at ../../../../../core/libs/libc/shared_em_64_perf/../core/gen/assert.c:57
#5 0xc0000000076a9080:0 in relocate_packets (src=0x6000000001c63c00,
dst_instance=0x60000000064f6800) at src/instance.c:542
#6 0xc0000000076a9b40:0 in lcb_update_serverlist (instance=0x60000000064f6800)
at src/instance.c:606
#7 0xc0000000076ac7e0:0 in vbucket_stream_handler (sock=31, which=2,
arg=0x60000000064f6800) at src/instance.c:996
#8 0xc000000007d6db60:0 in event_base_loop (base=0x6000000006381780,
flags=<not available>) at event.c:1346
#9 0xc000000000a3aed0:0 in lcb_io_run_event_loop (iops=0x60000000061bff20)
at plugins/io/libevent/plugin-libevent.c:324
#10 0xc0000000076c2750:0 in lcb_wait (instance=0x60000000064f6800)
at src/wait.c:60
#11 0xc0000000109c5e00:0 in Cache_Storage::CCouchbaseStorage::do_usefull_work (
--Type <return> to continue, or q <return> to quit--
this=0x6000000006224280) at cache_source/ucouchbasestorage.cpp:524
#12 0xc0000000109c7850:0 in Cache_Storage::CCouchbaseStorage::execute (
this=0x6000000006224280) at cache_source/ucouchbasestorage.cpp:585
#13 0xc00000000782c0f0:0 in threads::thread_proc (thr_ptr=0x60000000062242a0)
at has_common_source/source/cpp/threads.cpp:225
#14 0xc00000000013fb20:0 in __pthread_bound_body ()
at /ux/core/libs/threadslibs/src/common/pthreads/pthread.c:4875
(gdb) list
537 }
538 dst = dst_instance->servers + (lcb_size_t)idx;
539 if (src->connected)
else
{ 542 assert(ringbuffer_read(&src->pending_cookies, &ct, sizeof(ct)) == sizeof(ct)); 543 }544
545 assert(ringbuffer_ensure_capacity(&dst->cmd_log, npacket));
546 assert(ringbuffer_write(&dst->cmd_log, cmd.bytes, sizeof(cmd.bytes)) == sizeof(cmd.bytes));
(gdb) p src->pending_cookies
$5 =
(gdb) p src->connected
$7 = 0
lcb_size_t ringbuffer_read(ringbuffer_t *buffer, void *dest, lcb_size_t nb)
{
char *d = dest;
lcb_size_t nr = 0;
lcb_size_t space;
lcb_size_t toRead;
if (buffer->nbytes == 0)
{ return 0; }