History log of /6.0.3/kv_engine/engines/ep/src/executorthread.h (Results 1 - 25 of 66)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: v7.0.2, v6.6.3, v7.0.1, v7.0.0, v6.6.2, v6.5.2, v6.6.1, v6.0.5, v6.6.0, v6.5.1, v6.0.4, v6.5.0, v6.0.3
# e7ed2862 27-Aug-2019 Dave Rigby <daver@couchbase.com>

MB-35649: Remove ExecutorThread::waketime

Since the fix for MB-35649, this member variable is no longer used for
thread scheduling (wakeup); sleep time is now directly calculated from

MB-35649: Remove ExecutorThread::waketime

Since the fix for MB-35649, this member variable is no longer used for
thread scheduling (wakeup); sleep time is now directly calculated from
the futureQueue contents.

As such remove it.

Change-Id: Iaff9f9e7d19f12416000dd3a9b31bb41d5e9e12d
Reviewed-on: http://review.couchbase.org/114231
Well-Formed: Build Bot <build@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: James Harrison <james.harrison@couchbase.com>

show more ...


Revision tags: v5.5.4, v5.5.5, v5.5.6, v6.0.1, v5.5.3, v6.0.0, v5.1.3, v5.5.2, v5.5.1, v5.1.2, v5.1.1
# 44a3fd5d 15-May-2018 Dave Rigby <daver@couchbase.com>

MB-29675: Change Task::getDescription() back to std::string

Task::getDescription() currently returns a non-owning string
(const_char_buffer), instead of an owning std::string. This was c

MB-29675: Change Task::getDescription() back to std::string

Task::getDescription() currently returns a non-owning string
(const_char_buffer), instead of an owning std::string. This was chocen
to minimise string copying as getDescription was called multiple times
per task execution (for example for taskLog / slowTaskLog - see
d26ea7d1f12aa021e74663a304d81d1f9e512097 which originally changed to
const_char_buffer.

However now taskLog / slowTaskLog have been removed, we will no longer
call getDescription anywhere near as frequently - short-running tasks
will likely never have their description requested. As such
pre-calculating the description (and having to ensure it's lifetime is
as long as any caller requesting it) is now less efficient than simply
generating it on-demand.

Change getDescription back to std::string, only creating a string
object on demand when it is requested.

Change-Id: I5f003b76d0ac73b2abc3ac5cd3d985a6ceb867c3
Reviewed-on: http://review.couchbase.org/94283
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>

show more ...


# d3d41268 14-May-2018 Dave Rigby <daver@couchbase.com>

MB-29675: Remove ExecutorThread taskLog & slowLog

ExecutorThread contains two ring buffers detailing the name, type and
runtime of:

a) The last 80 tasks executed.

b) th

MB-29675: Remove ExecutorThread taskLog & slowLog

ExecutorThread contains two ring buffers detailing the name, type and
runtime of:

a) The last 80 tasks executed.

b) the last 80 "slow" tasks (ones which exceed their expected
runtime).

However these logs are now of limited value:

- They only record a very small number of elements (particulary the
'taskLog'), the information is typically of little use by the time
it's captured in stats.

- The information is presented in a separate stats block (with a
different timestamp format), making it hard to correlate back to the
main memcached log (which is typically needed to actually make use
of the information).

- The cost of logging is non-zero - for each recorded log element,
there is one memory allocation for std::string, potentially an
additional allocation when appending the description to the task
name.

Now we have Phosphor tracing in KV-Engine, the taskLog/slowLog don't
really add anything - Phosphor provides ~400,000 events in the default
20MB trace buffer; and has an extremly low cost - no per-event memory
allocation.

As such; remove the taskLogs.

Change-Id: I2389b10ad3a1ad89c32db2037673f6c45107ebb3
Reviewed-on: http://review.couchbase.org/94162
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


Revision tags: v5.0.1, v5.1.0, v5.0.0
# f48fae53 16-May-2017 Jim Walker <jim@couchbase.com>

MB-24394: Peform an unlocked reset of ExecutorThread::currentTask

When performing currentTask.reset with currentTaskMutex held a
lock inversion situation occurs if:

* the task h

MB-24394: Peform an unlocked reset of ExecutorThread::currentTask

When performing currentTask.reset with currentTaskMutex held a
lock inversion situation occurs if:

* the task hits a ref-count of 0
* the task owns a VBucketPtr (shared_ptr)
* the VBucket is marked for deferred deletion
* the VBucketPtr hits a ref-count of 0

This occurs because the VBucketPtr deleter will schedule a new task
to delete the VBucket and thus we re-enter the task code with a
different lock ordering (TaskQueue::tMutex->currentTaskMutex vs
currentTaskMutex->TaskQueue::tMutex).

To fix this issue we simply need to not hold the currentTaskMutex
whilst calling currentTask.reset().

We switch ExTask over to being a std::shared_ptr and use its well
define move constructor (via std::move) to move the ref-counted
pointer into unlocked scope, and then reset that.

Change-Id: I883cb4d0e8a2c4dbc91cdf93f0a9a967863dcb31
Reviewed-on: http://review.couchbase.org/78643
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


# ef22f9b0 25-May-2017 Dave Rigby <daver@couchbase.com>

Move ep-engine to engines/ep


# 74551d34 28-Apr-2017 Dave Rigby <daver@couchbase.com>

Remove unnecessary #include "tasks.h"

tasks.h is a relatively expensive header to include, as it contains
the definitions of various disjoint Task types, so in turn it includes
a lar

Remove unnecessary #include "tasks.h"

tasks.h is a relatively expensive header to include, as it contains
the definitions of various disjoint Task types, so in turn it includes
a large proportion of ep-engine headers.

However, it is unneessarily included in a large number of places. This
is probably at last in part due to the fact that globaltask.h didn't
used to be it's own header, and hence to get the GlobalTask definition
one needed to include tasks.h

Change-Id: I0971eab4808ce51d470fe061c13796d18b444234
Reviewed-on: http://review.couchbase.org/77498
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


Revision tags: v4.6.2_ep, v4.6.2_mc, v4.6.1_ep
# 7dfe4a57 24-Feb-2017 James Harrison <00jamesh@gmail.com>

MB-22018: Add tasks stats to cbstats

Initial work on adding a "top" like tool showing tasks running and
sleeping in a cluster.

This can be viewed by running

cbstats

MB-22018: Add tasks stats to cbstats

Initial work on adding a "top" like tool showing tasks running and
sleeping in a cluster.

This can be viewed by running

cbstats host:port tasks

This shows the information about the tasks such as the state, next
runtime, description, type etc.

Future additions to the tool are intended to add features such as load
averages for task types (of the style shown by `uptime`) and percentage
utilisation over a period of time per thread.

Change-Id: I005a2589a35b4c4364ba46cf2b44b71061ba06b3
Reviewed-on: http://review.couchbase.org/74510
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


# d26ea7d1 20-Mar-2017 Dave Rigby <daver@couchbase.com>

Change GlobalTask::getDescription to return cb::const_char_buffer

The pure virtual method GlobalTask::getDescription() returns a
std::string object. This method is actually called very f

Change GlobalTask::getDescription to return cb::const_char_buffer

The pure virtual method GlobalTask::getDescription() returns a
std::string object. This method is actually called very frequently by
the ExecutorThreads (to log task execution / slow tasks), and hence
passing a concrete object is potentially costly, requiring an
allocation (and then deletion) for each call.

Given that the description is mostly constant for the lifetime of a
Task, change the method to return cb::const_char_buffer - i.e. a
read-only non-owning view. This reduces to passing essentially two
words, removing all memory allocation.

Change-Id: I3cd68798d97401a3d5b50c9720c87dade2a1b32e
Reviewed-on: http://review.couchbase.org/75435
Reviewed-by: Jim Walker <jim@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


# 11d62689 09-Feb-2017 Dave Rigby <daver@couchbase.com>

Cleanup #include usage in headers

'Include what you use':

- remove unnecessary #include directives from source files, focusing
on removing from header files (where they can ca

Cleanup #include usage in headers

'Include what you use':

- remove unnecessary #include directives from source files, focusing
on removing from header files (where they can cause unnecessary
rebuilding.

- Move #includes from .h to .cc where applicable.

- Use forward declarions instead of #include'ing the whole header
where possible.

- Remove unnecessary inlining of non-hot / non-trivial code by moving
to .cc files.

Change-Id: I35a757fe92e637ce47454ef84332e89ec94937d3
Reviewed-on: http://review.couchbase.org/73457
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


# e7ce1c4f 08-Feb-2017 James Harrison <00jamesh@gmail.com>

MB-22041 [3/N]: Allow dynamic changes to number of threads

Reader, Writer, AuxIO and NonIO threads can now be dynamically stopped
and started using the interface previously used to set t

MB-22041 [3/N]: Allow dynamic changes to number of threads

Reader, Writer, AuxIO and NonIO threads can now be dynamically stopped
and started using the interface previously used to set the maximum
number of these threads - i.e., setMaxReaders.

The behaviour is outwardly the same - the max controls how many tasks of
a given type can be run concurrently, but this can now be dynamically
tuned both upwards and downwards.

Change-Id: I8e10487e5b57466fbe299e7e043a90dd6c8d5aa8
Reviewed-on: http://review.couchbase.org/73304
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Manu Dhundi <manu@couchbase.com>

show more ...


# 9a55aa87 14-Dec-2016 WillGardner <willg@rdner.io>

Replace RingBuffer with cb::RingBuffer from platform

To reduce the amount of code we keep around. Also cb::RingBuffer
behaves more like an STL container.

Change-Id: Iba06562c9b4

Replace RingBuffer with cb::RingBuffer from platform

To reduce the amount of code we keep around. Also cb::RingBuffer
behaves more like an STL container.

Change-Id: Iba06562c9b409944310792469c8a1b1fc42afa77
Reviewed-on: http://review.couchbase.org/70960
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


Revision tags: v4.6.0_ep
# d8577c54 15-Nov-2016 Daniel Owen <owend@couchbase.com>

MB-20079: Use std::chrono::steady_clock (ProcessClock)

Change task scheduling to use ProcessClock which is not
affected by changes to wall clock time.

Change-Id: I2fc9688abb782f

MB-20079: Use std::chrono::steady_clock (ProcessClock)

Change task scheduling to use ProcessClock which is not
affected by changes to wall clock time.

Change-Id: I2fc9688abb782fe2c9e80efb6da840be3643d4a5
Reviewed-on: http://review.couchbase.org/69899
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>

show more ...


Revision tags: v4.5.1-MP1_mc, v4.6.0-DP_mc, v4.6.0-DP_ep, v4.5.1-MP1_ep, v4.1.2-MP2_mc, v4.5.1_mc, v4.6.0_mc, v4.1.2-MP1_ep, v3.1.6_ep
# b77fd62a 16-Jun-2016 Dave Rigby <daver@couchbase.com>

MB-20054: Backport ep-engine_unit_tests from watson to 3.0.x

In Watson we have created a set of 'unit' (i.e. class-level) tests for
ep-engine. To assist in backporting bug fixes, and spe

MB-20054: Backport ep-engine_unit_tests from watson to 3.0.x

In Watson we have created a set of 'unit' (i.e. class-level) tests for
ep-engine. To assist in backporting bug fixes, and specifically their
unit tests (to demonstrate they are correct), this patch backports the
test infrastructure itself.

Note these tests require GTest, so the CMake changes necessary for it
have also been included.

Tests are a backport from couchbase/watson as of commit feda304.
Modified to handle changes in APIs etc, and to remove tests
which fail on 3.0.x as we never chose to fix them in the 3.0.x
branch.

Change-Id: Iaaf59b0d8d6ba0a2211b630ba00fd837ca01614a
Reviewed-on: http://review.couchbase.org/64979
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>

show more ...


Revision tags: v4.5.0_mc, v4.5.0_ep, v4.1.1_ep, v3.1.5_ep, v4.1.1_mc
# 66bb41ad 04-Mar-2016 Dave Rigby <daver@couchbase.com>

Remove AtomicValue and Mutex defines

We already removed our own custom AtomicValue and Mutex classes when
we moved to C++11; replacing them with #defines to std::atomic and
std::mute

Remove AtomicValue and Mutex defines

We already removed our own custom AtomicValue and Mutex classes when
we moved to C++11; replacing them with #defines to std::atomic and
std::mutex respectively. This patch completes that changover, using
the underlying types directly so it's easier to see what is actually
being used.

Change-Id: If3f717f766727042cd81ae7b8c65f9a19934f2fa
Reviewed-on: http://review.couchbase.org/60925
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>

show more ...


# c9a6de87 20-May-2016 Dave Rigby <daver@couchbase.com>

Regression / unit test for MB-19695

Regression / unit test for MB-19695. See MB for full background of the
problem.

Given the issue is triggered by an unfortunate Task execution

Regression / unit test for MB-19695

Regression / unit test for MB-19695. See MB for full background of the
problem.

Given the issue is triggered by an unfortunate Task execution order,
creating a unit test for it requires that we can explicitly control
when Tasks and scheduled and executed.

To do this a FakeExecutorPool has been created. It maintains the same
set of Tasks on taskqueues, but no ExecutorThreads exist. Tasks can be
manually fetched from the queues, and then manually run on a
FakeExecutorThread (just runs the Task on the main thread). This
allows unit tests to have complete control on when Tasks are woken up
and run.

Change-Id: I6ef6e051a633c799740aa948eb7531974f94a949
Reviewed-on: http://review.couchbase.org/64253
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>

show more ...


Revision tags: v3.1.4_ep, v3.1.4_mc, v3.1.5_mc, v3.1.3_ep, v4.1.0_ep, v3.1.2_ep, v4.1.0_mc
# 6387cef8 22-Oct-2015 abhinavdangeti <abhinav@couchbase.com>

MB-19277: Set executorThread's waketime to atomic

This one looks benign - we only perform the dirty read when
calculating the %s:waketime stat which is not used by anyone apart
from

MB-19277: Set executorThread's waketime to atomic

This one looks benign - we only perform the dirty read when
calculating the %s:waketime stat which is not used by anyone apart
from end-users.

WARNING: ThreadSanitizer: data race (pid=41666)
Read of size 8 at 0x7d4400008370 by main thread (mutexes: write M21616):
#0 ExecutorThread::getWaketime() ep-engine/src/executorthread.h:120 (ep.so+0x0000001cac0e)
#1 addWorkerStats(char const*, ExecutorThread*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/executorpool.cc:692 (ep.so+0x0000001b6f06)
#2 ExecutorPool::doWorkerStat(EventuallyPersistentEngine*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/executorpool.cc:706 (ep.so+0x0000001b6734)
#3 EventuallyPersistentEngine::doDispatcherStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:4139 (ep.so+0x00000015223e)
#4 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:4375 (ep.so+0x000000155336)

Previous write of size 8 at 0x7d4400008370 by thread T6 (mutexes: write M14985):
#0 TaskQueue::_fetchNextTask(ExecutorThread&, bool) ep-engine/src/taskqueue.cc:125 (ep.so+0x00000025b3fd)
#1 TaskQueue::fetchNextTask(ExecutorThread&, bool) ep-engine/src/taskqueue.cc:161 (ep.so+0x00000025bfcf)
#2 ExecutorPool::_nextTask(ExecutorThread&, unsigned char) ep-engine/src/executorpool.cc:217 (ep.so+0x0000001afc67)
#3 ExecutorPool::nextTask(ExecutorThread&, unsigned char) ep-engine/src/executorpool.cc:232 (ep.so+0x0000001afe3f)
#4 ExecutorThread::run() ep-engine/src/executorthread.cc:81 (ep.so+0x0000001e85c9)

Change-Id: I34b12681dd9dfc87c889f301692ca714f04d2a82
Reviewed-on: http://review.couchbase.org/63029
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>
Tested-by: buildbot <build@couchbase.com>

show more ...


# 1d61bf30 08-Dec-2015 abhinavdangeti <abhinav@couchbase.com>

MB-19276: Fix data race on ExecutorThread::taskStart

WARNING: ThreadSanitizer: data race (pid=236996)
Write of size 8 at 0x7d380000dbd8 by thread T5:
#0 ExecutorThread::run() e

MB-19276: Fix data race on ExecutorThread::taskStart

WARNING: ThreadSanitizer: data race (pid=236996)
Write of size 8 at 0x7d380000dbd8 by thread T5:
#0 ExecutorThread::run() ep-engine/src/executorthread.cc:105 (ep.so+0x0000000ee0cc)
#1 launch_executor_thread(void*) ep-engine/src/executorthread.cc:33 (ep.so+0x0000000edd75)
#2 platform_thread_wrap(void*) platform/src/cb_pthreads.cc:54 (libplatform.so.0.1.0+0x000000004e7b)

Previous read of size 8 at 0x7d380000dbd8 by main thread (mutexes: write M266835151185571736):
#0 addWorkerStats(char const*, ExecutorThread*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/executorthread.h:108 (ep.so+0x0000000ea8dc)
#1 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:4363 (ep.so+0x0000000c05dd)
#2 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:219 (ep.so+0x0000000af40e)
#3 mock_get_stats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) memcached/programs/engine_testapp/engine_testapp.cc:240 (engine_testapp+0x0000004cc71d)
#4 test_worker_stats(engine_interface*, engine_interface_v1*) ep-engine/tests/ep_testsuite.cc:9464 (ep_testsuite.so+0x00000003c038)
#5 execute_test(test, char const*, char const*) memcached/programs/engine_testapp/engine_testapp.cc:1091 (engine_testapp+0x0000004cb315)
#6 __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 (libc.so.6+0x00000002176c)

Change-Id: If01aba3cf6b3591f19c5bb62119e40998f12c8ff
Reviewed-on: http://review.couchbase.org/63028
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>
Tested-by: buildbot <build@couchbase.com>

show more ...


# 4bc74ba8 08-Oct-2015 Dave Rigby <daver@couchbase.com>

MB-19257: Fix data race on ExecutorThread::now

This value is accessed without a lock from addWorkerStats. Change to
atomic to fix race.

As reported by ThreadSanitizer:

MB-19257: Fix data race on ExecutorThread::now

This value is accessed without a lock from addWorkerStats. Change to
atomic to fix race.

As reported by ThreadSanitizer:

WARNING: ThreadSanitizer: data race (pid=18761)
Read of size 8 at 0x7d4400007fa8 by main thread (mutexes: write M19371):
#0 ExecutorThread::getCurTime() /home/couchbase/server/ep-engine/src/executorthread.h:129:46 (ep.so+0x0000000e67a0)
#1 addWorkerStats(char const*, ExecutorThread*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/executorpool.cc:748 (ep.so+0x0000000e67a0)
#2 ExecutorPool::doWorkerStat(EventuallyPersistentEngine*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/executorpool.cc:760 (ep.so+0x0000000e67a0)
#3 EventuallyPersistentEngine::doDispatcherStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/ep_engine.cc:4352:5 (ep.so+0x0000000bc72d)
#4 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/ep_engine.cc:4588 (ep.so+0x0000000bc72d)
#5 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/ep_engine.cc:214:38 (ep.so+0x0000000ab70e)
#6 mock_get_stats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/memcached/programs/engine_testapp/engine_testapp.cc:239:19 (engine_testapp+0x0000004c553d)
#7 test_worker_stats(engine_interface*, engine_interface_v1*) /home/couchbase/server/ep-engine/tests/ep_testsuite.cc:8901:24 (ep_testsuite.so+0x000000039908)
#8 execute_test(test, char const*, char const*) /home/couchbase/server/memcached/programs/engine_testapp/engine_testapp.cc:1090:19 (engine_testapp+0x0000004c4142)
#9 main /home/couchbase/server/memcached/programs/engine_testapp/engine_testapp.cc:1439 (engine_testapp+0x0000004c4142)

Previous write of size 8 at 0x7d4400007fa8 by thread T7 (mutexes: write M12645):
#0 TaskQueue::_doSleep(ExecutorThread&) /home/couchbase/server/ep-engine/src/taskqueue.cc:78:5 (ep.so+0x00000012eb21)
#1 TaskQueue::_fetchNextTask(ExecutorThread&, bool) /home/couchbase/server/ep-engine/src/taskqueue.cc:117:21 (ep.so+0x00000012ed66)
#2 TaskQueue::fetchNextTask(ExecutorThread&, bool) /home/couchbase/server/ep-engine/src/taskqueue.cc:160:17 (ep.so+0x00000012f907)
#3 ExecutorPool::_nextTask(ExecutorThread&, unsigned char) /home/couchbase/server/ep-engine/src/executorpool.cc:226:17 (ep.so+0x0000000dfa6f)
#4 ExecutorPool::nextTask(ExecutorThread&, unsigned char) /home/couchbase/server/ep-engine/src/executorpool.cc:241:21 (ep.so+0x0000000dfac6)
#5 ExecutorThread::run() /home/couchbase/server/ep-engine/src/executorthread.cc:81:28 (ep.so+0x0000000e9cfe)
#6 launch_executor_thread(void*) /home/couchbase/server/ep-engine/src/executorthread.cc:33:9 (ep.so+0x0000000e9b05)
#7 platform_thread_wrap /home/couchbase/server/platform/src/cb_pthreads.c:23:5 (libplatform.so.0.1.0+0x000000003dc1)

Change-Id: Idcaea9a157293dbf95ca236354673556a2f3c4ac
Reviewed-on: http://review.couchbase.org/62975
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>
Tested-by: buildbot <build@couchbase.com>

show more ...


# 644c09df 06-Oct-2015 Dave Rigby <daver@couchbase.com>

MB-19253: Fix race in void ExecutorPool::doWorkerStat

As reported by ThreadSanitizer (see below), there is a race between
setting the current task associated with a ExecutorThread and re

MB-19253: Fix race in void ExecutorPool::doWorkerStat

As reported by ThreadSanitizer (see below), there is a race between
setting the current task associated with a ExecutorThread and reading
the name of that thread.

Unfortunately there doesn't seem to be a straightforward way to solve
this without adding a new mutex; currentTask (the variable the race is
on) is a SingleThreadedRCPtr, which is non-trivial to make thread-safe
(i.e. atomic). I did consider changing currenTask (and all other
ExTask variables) to be a std::shared_ptr as in C++11 this has support
for updating atomically, however the support in mainstream compilers
apparently isn't quite there yet.

Therefore I've just added a mutex to guard currentTask.

ThreadSanitizer report:

WARNING: ThreadSanitizer: data race (pid=27332)
Read of size 8 at 0x7d340000c8f0 by main thread (mutexes: write M19366):
#0 ExecutorThread::getTaskableName() const /home/couchbase/couchbase/ep-engine/src/atomic.h:309 (ep.so+0x0000000e6178)
#1 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/couchbase/ep-engine/src/ep_engine.cc:4346 (ep.so+0x0000000bc4dd)
#2 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/couchbase/ep-engine/src/ep_engine.cc:213 (ep.so+0x0000000ab49e)
#3 mock_get_stats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/couchbase/memcached/programs/engine_testapp/engine_testapp.cc:239 (engine_testapp+0x0000004c54ad)
#4 test_worker_stats(engine_interface*, engine_interface_v1*) /home/couchbase/couchbase/ep-engine/tests/ep_testsuite.cc:8901 (ep_testsuite.so+0x000000039768)
#5 execute_test(test, char const*, char const*) /home/couchbase/couchbase/memcached/programs/engine_testapp/engine_testapp.cc:1090 (engine_testapp+0x0000004c40b2)
#6 __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 (libc.so.6+0x00000002176c)

Previous write of size 8 at 0x7d340000c8f0 by thread T5:
#0 ExecutorThread::run() /home/couchbase/couchbase/ep-engine/src/atomic.h:322 (ep.so+0x0000000e9906)
#1 launch_executor_thread(void*) /home/couchbase/couchbase/ep-engine/src/executorthread.cc:33 (ep.so+0x0000000e9795)
#2 platform_thread_wrap /home/couchbase/.ccache/tmp/cb_pthread.tmp.00b591814417.18511.i (libplatform.so.0.1.0+0x000000003d91)

Change-Id: Id02f7a98b40b952a415cf9027a8f2243af38fc4d
Reviewed-on: http://review.couchbase.org/62973
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>
Tested-by: buildbot <build@couchbase.com>

show more ...


Revision tags: v3.1.2_mc, v3.1.1_mc, v3.1.1_ep, v4.0.0_ep
# 5dbbb7c2 23-Jul-2015 Sundar Sridharan <sundar.sridharan@gmail.com>

MB-19223: Switch to hrtime from timeval in Global Thread Pool

This has small improvements in memory and cpu usage.
Also fixes several ThreadSanitizer races from unit tests - for example:

MB-19223: Switch to hrtime from timeval in Global Thread Pool

This has small improvements in memory and cpu usage.
Also fixes several ThreadSanitizer races from unit tests - for example:

WARNING: ThreadSanitizer: data race (pid=21672)
Write of size 8 at 0x7d140000e7b8 by main thread (mutexes: write M14972, write M14985):
#0 memcpy <null> (engine_testapp+0x000000453040)
#1 TaskQueue::_wake(SingleThreadedRCPtr<GlobalTask>&) /home/daver/repos/couchbase/server/ep-engine/src/taskqueue.cc:255 (ep.so+0x0000002577f6)
#2 TaskQueue::wake(SingleThreadedRCPtr<GlobalTask>&) /home/daver/repos/couchbase/server/ep-engine/src/taskqueue.cc:282 (ep.so+0x000000257c73)
#3 ExecutorPool::_wake(unsigned long) /home/daver/repos/couchbase/server/ep-engine/src/executorpool.cc:320 (ep.so+0x0000001acc76)
#4 ExecutorPool::wake(unsigned long) /home/daver/repos/couchbase/server/ep-engine/src/executorpool.cc:328 (ep.so+0x0000001ace13)
#5 Flusher::wait() /home/daver/repos/couchbase/server/ep-engine/src/flusher.cc:41 (ep.so+0x0000001cc4ff)
#6 EventuallyPersistentStore::stopFlusher() /home/daver/repos/couchbase/server/ep-engine/src/ep.cc:402 (ep.so+0x0000000d54d5)
#7 ~EventuallyPersistentStore /home/daver/repos/couchbase/server/ep-engine/src/ep.cc:364 (ep.so+0x0000000d49cb)
#8 ~EventuallyPersistentEngine /home/daver/repos/couchbase/server/ep-engine/src/ep_engine.cc:5778 (ep.so+0x000000161043)
#9 EvpDestroy(engine_interface*, bool) /home/daver/repos/couchbase/server/ep-engine/src/ep_engine.cc:143 (ep.so+0x000000135efa)
#10 mock_destroy /home/daver/repos/couchbase/server/memcached/programs/engine_testapp/engine_testapp.c:61 (engine_testapp+0x0000004bb9d6)
#11 destroy_engine /home/daver/repos/couchbase/server/memcached/programs/engine_testapp/engine_testapp.c:998 (engine_testapp+0x0000004bb646)
#12 execute_test /home/daver/repos/couchbase/server/memcached/programs/engine_testapp/engine_testapp.c:1048 (engine_testapp+0x0000004baa11)
#13 main /home/daver/repos/couchbase/server/memcached/programs/engine_testapp/engine_testapp.c:1296 (engine_testapp+0x0000004b8861)

Previous read of size 8 at 0x7d140000e7b8 by thread T14:
#0 ExecutorThread::run() /home/daver/repos/couchbase/server/ep-engine/src/executorthread.cc:106 (ep.so+0x0000001e3488)
#1 launch_executor_thread(void*) /home/daver/repos/couchbase/server/ep-engine/src/executorthread.cc:34 (ep.so+0x0000001e2a5a)
#2 platform_thread_wrap /home/daver/repos/couchbase/server/platform/src/cb_pthreads.c:19 (libplatform.so.0.1.0+0x0000000035dc)

Change-Id: I78fdddb832251fc062058c04f75f8d22c4c2f68d
Reviewed-on: http://review.couchbase.org/62912
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>

show more ...


Revision tags: v4.0.0_mc, v3.1.0_ep, v3.1.0_mc, v3.1.6_mc, v3.0.2-MP2_mc, v3.0.2_ep, v3.0.2_mc
# 8cbe913f 12-Nov-2014 Dave Rigby <daver@couchbase.com>

MB-19222: Fix race condition in TaskQueue shutdown

There is a bug in the use of ExecutorThread.state when sleeping a
TaskQueue - TaskQueue::_doSleep() doesn't atomically transition the

MB-19222: Fix race condition in TaskQueue shutdown

There is a bug in the use of ExecutorThread.state when sleeping a
TaskQueue - TaskQueue::_doSleep() doesn't atomically transition the
state from RUNNING -> SLEEPING. This can cause a deadlock when
shutting down a ExecutorThread:

Thread A: Thread B:
-------------------------------- ------------------------------
if (t.state == RUNNING) { // true
t.state = SHUTDOWN
t.state = SLEEPING cb_join_thread(Thread A)
// wait forever
...
if (t.state == SHUTDOWN) { // FALSE
exit(0) // NEVER REACHED
}

Fix by changing ExecutorThread.state to be an AtomicValue, and use
compare-and-exchange to move from RUNNING -> SLEEPING (and SLEEPING ->
RUNNING).

Change-Id: I9fab90a83978ae2aa6a0dcdd3b079a1c2f369402
Reviewed-on: http://review.couchbase.org/62911
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>

show more ...


# 3034a75d 08-Dec-2015 abhinavdangeti <abhinav@couchbase.com>

Fix data race in executor thread

WARNING: ThreadSanitizer: data race (pid=236996)
Write of size 8 at 0x7d380000dbd8 by thread T5:
#0 ExecutorThread::run() /home/couchbase/jenki

Fix data race in executor thread

WARNING: ThreadSanitizer: data race (pid=236996)
Write of size 8 at 0x7d380000dbd8 by thread T5:
#0 ExecutorThread::run() /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/executorthread.cc:105 (ep.so+0x0000000ee0cc)
#1 launch_executor_thread(void*) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/executorthread.cc:33 (ep.so+0x0000000edd75)
#2 platform_thread_wrap(void*) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/platform/src/cb_pthreads.cc:54 (libplatform.so.0.1.0+0x000000004e7b)

Previous read of size 8 at 0x7d380000dbd8 by main thread (mutexes: write M266835151185571736):
#0 addWorkerStats(char const*, ExecutorThread*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/executorthread.h:108 (ep.so+0x0000000ea8dc)
#1 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/ep_engine.cc:4363 (ep.so+0x0000000c05dd)
#2 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/ep_engine.cc:219 (ep.so+0x0000000af40e)
#3 mock_get_stats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/memcached/programs/engine_testapp/engine_testapp.cc:240 (engine_testapp+0x0000004cc71d)
#4 test_worker_stats(engine_interface*, engine_interface_v1*) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/ep_testsuite.cc:9464 (ep_testsuite.so+0x00000003c038)
#5 execute_test(test, char const*, char const*) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/memcached/programs/engine_testapp/engine_testapp.cc:1091 (engine_testapp+0x0000004cb315)
#6 __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 (libc.so.6+0x00000002176c)

Change-Id: If01aba3cf6b3591f19c5bb62119e40998f12c8ff
Reviewed-on: http://review.couchbase.org/57593
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>

show more ...


# e7754280 05-Nov-2015 Dave Rigby <daver@couchbase.com>

Simplify common.h: Remove unnecessary headers [3/3]

Remove all #includes which arn't actually needed by the file including
them (aka "include what you use").

Reduces build time

Simplify common.h: Remove unnecessary headers [3/3]

Remove all #includes which arn't actually needed by the file including
them (aka "include what you use").

Reduces build time down from before this patch series from:

31.82 real 222.13 user 16.09 sys

down to:

26.95 real 188.54 user 13.29 sys

giving a 15% speedup in (user+sys).

(Built using `make clean && CCACHE_DISABLE=1 time make -j8`)

Change-Id: Ia47f08487d20c94167d93de8dd6590f7703dd898
Reviewed-on: http://review.couchbase.org/56705
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>

show more ...


# b4fdd651 22-Oct-2015 abhinavdangeti <abhinav@couchbase.com>

Set executorThread's waketime to atomic

WARNING: ThreadSanitizer: data race (pid=154525)
Write of size 8 at 0x7d44000084b0 by thread T5 (mutexes: write M12649):
#0 TaskQueue::_

Set executorThread's waketime to atomic

WARNING: ThreadSanitizer: data race (pid=154525)
Write of size 8 at 0x7d44000084b0 by thread T5 (mutexes: write M12649):
#0 TaskQueue::_doSleep(ExecutorThread&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/taskqueue.cc:109 (ep.so+0x000000130126)
#1 TaskQueue::_fetchNextTask(ExecutorThread&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/taskqueue.cc:117 (ep.so+0x000000130186)
#2 TaskQueue::fetchNextTask(ExecutorThread&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/taskqueue.cc:160 (ep.so+0x000000130d27)
#3 ExecutorPool::_nextTask(ExecutorThread&, unsigned char) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/executorpool.cc:226 (ep.so+0x0000000e09ef)
#4 ExecutorPool::nextTask(ExecutorThread&, unsigned char) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/executorpool.cc:241 (ep.so+0x0000000e0a46)
#5 ExecutorThread::run() /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/executorthread.cc:81 (ep.so+0x0000000eace9)
#6 launch_executor_thread(void*) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/executorthread.cc:33 (ep.so+0x0000000eaad5)
#7 platform_thread_wrap(void*) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/platform/src/cb_pthreads.cc:53 (libplatform.so.0.1.0+0x0000000048bb)

Previous read of size 8 at 0x7d44000084b0 by main thread (mutexes: write M432483174979792312):
#0 addWorkerStats(char const*, ExecutorThread*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/executorthread.h:127 (ep.so+0x0000000e76f5)
#1 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/ep_engine.cc:4360 (ep.so+0x0000000bd6ad)
#2 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/ep_engine.cc:216 (ep.so+0x0000000ac68e)
#3 mock_get_stats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/memcached/programs/engine_testapp/engine_testapp.cc:239 (engine_testapp+0x0000004c558d)
#4 test_worker_stats(engine_interface*, engine_interface_v1*) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/ep_testsuite.cc:8915 (ep_testsuite.so+0x000000039b38)
#5 execute_test(test, char const*, char const*) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/memcached/programs/engine_testapp/engine_testapp.cc:1090 (engine_testapp+0x0000004c4192)
#6 __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 (libc.so.6+0x00000002176c)

Change-Id: I34b12681dd9dfc87c889f301692ca714f04d2a82
Reviewed-on: http://review.couchbase.org/56307
Reviewed-by: Sriram Ganesan <sriram@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>

show more ...


# 418f6d5e 08-Oct-2015 Dave Rigby <daver@couchbase.com>

Fix data race on ExecutorThread::now

This value is accessed without a lock from addWorkerStats. Change to
atomic to fix race.

As reported by ThreadSanitizer:

WARNING: T

Fix data race on ExecutorThread::now

This value is accessed without a lock from addWorkerStats. Change to
atomic to fix race.

As reported by ThreadSanitizer:

WARNING: ThreadSanitizer: data race (pid=18761)
Read of size 8 at 0x7d4400007fa8 by main thread (mutexes: write M19371):
#0 ExecutorThread::getCurTime() /home/couchbase/server/ep-engine/src/executorthread.h:129:46 (ep.so+0x0000000e67a0)
#1 addWorkerStats(char const*, ExecutorThread*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/executorpool.cc:748 (ep.so+0x0000000e67a0)
#2 ExecutorPool::doWorkerStat(EventuallyPersistentEngine*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/executorpool.cc:760 (ep.so+0x0000000e67a0)
#3 EventuallyPersistentEngine::doDispatcherStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/ep_engine.cc:4352:5 (ep.so+0x0000000bc72d)
#4 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/ep_engine.cc:4588 (ep.so+0x0000000bc72d)
#5 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/ep-engine/src/ep_engine.cc:214:38 (ep.so+0x0000000ab70e)
#6 mock_get_stats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/couchbase/server/memcached/programs/engine_testapp/engine_testapp.cc:239:19 (engine_testapp+0x0000004c553d)
#7 test_worker_stats(engine_interface*, engine_interface_v1*) /home/couchbase/server/ep-engine/tests/ep_testsuite.cc:8901:24 (ep_testsuite.so+0x000000039908)
#8 execute_test(test, char const*, char const*) /home/couchbase/server/memcached/programs/engine_testapp/engine_testapp.cc:1090:19 (engine_testapp+0x0000004c4142)
#9 main /home/couchbase/server/memcached/programs/engine_testapp/engine_testapp.cc:1439 (engine_testapp+0x0000004c4142)

Previous write of size 8 at 0x7d4400007fa8 by thread T7 (mutexes: write M12645):
#0 TaskQueue::_doSleep(ExecutorThread&) /home/couchbase/server/ep-engine/src/taskqueue.cc:78:5 (ep.so+0x00000012eb21)
#1 TaskQueue::_fetchNextTask(ExecutorThread&, bool) /home/couchbase/server/ep-engine/src/taskqueue.cc:117:21 (ep.so+0x00000012ed66)
#2 TaskQueue::fetchNextTask(ExecutorThread&, bool) /home/couchbase/server/ep-engine/src/taskqueue.cc:160:17 (ep.so+0x00000012f907)
#3 ExecutorPool::_nextTask(ExecutorThread&, unsigned char) /home/couchbase/server/ep-engine/src/executorpool.cc:226:17 (ep.so+0x0000000dfa6f)
#4 ExecutorPool::nextTask(ExecutorThread&, unsigned char) /home/couchbase/server/ep-engine/src/executorpool.cc:241:21 (ep.so+0x0000000dfac6)
#5 ExecutorThread::run() /home/couchbase/server/ep-engine/src/executorthread.cc:81:28 (ep.so+0x0000000e9cfe)
#6 launch_executor_thread(void*) /home/couchbase/server/ep-engine/src/executorthread.cc:33:9 (ep.so+0x0000000e9b05)
#7 platform_thread_wrap /home/couchbase/server/platform/src/cb_pthreads.c:23:5 (libplatform.so.0.1.0+0x000000003dc1)

Change-Id: Idcaea9a157293dbf95ca236354673556a2f3c4ac
Reviewed-on: http://review.couchbase.org/55926
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>

show more ...


123