From 1d02d4bd9b5f7d730ab08961c17ef58204c8e8fd Mon Sep 17 00:00:00 2001 From: Joseph Fernandes Date: Fri, 11 Sep 2015 09:36:06 -0400 Subject: tier/ctr: Solving DB Lock issue due to write contention from db connections This is a backport of 12031. > Problem: The DB on the brick is been accessed by CTR, for write and > tier migrator, for read and write. The write from tier migrator is reseting > the heat counters after a cycle. Since we are using sqlite, two connections > trying to write would cause a db lock contention. As a result CTR used to fail > to update the db. > Solution: Using the same db connection of CTR for reseting the heat counters. > 1) Introducted a new IPC FOP for CTR > 2) After the query do a ipc syncop to the underlying client xlator associated > to the brick. > 3) CTR in brick will catch the IPC FOP and cleat the heat counters. > Change-Id: I53306bfc08dcdba479deb4ccc154896521336150 > BUG: 1260730 > Signed-off-by: Joseph Fernandes > Reviewed-on: http://review.gluster.org/12031 > Tested-by: NetBSD Build System > Tested-by: Gluster Build System Signed-off-by: Dan Lambright Conflicts: xlators/cluster/dht/src/tier.c Change-Id: I88aa289cdf21e216b42c3d8ccfb4e7e828b43772 BUG: 1262341 Reviewed-on: http://review.gluster.org/12161 Reviewed-by: Joseph Fernandes Tested-by: NetBSD Build System Tested-by: Gluster Build System Tested-by: Dan Lambright --- .../changetimerecorder/src/changetimerecorder.c | 34 +++++++++++++++++++++- .../features/changetimerecorder/src/ctr-helper.h | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'xlators/features/changetimerecorder') diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.c b/xlators/features/changetimerecorder/src/changetimerecorder.c index 7fd62584752..8acd811a0cb 100644 --- a/xlators/features/changetimerecorder/src/changetimerecorder.c +++ b/xlators/features/changetimerecorder/src/changetimerecorder.c @@ -1379,6 +1379,36 @@ out: fd, size, off, flags, xdata); return 0; } + +/*******************************ctr_ipc****************************************/ + +/* IPC Call from tier migrator to clear the heat on the DB */ +int32_t +ctr_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) +{ + int ret = -1; + gf_ctr_private_t *_priv = NULL; + + GF_ASSERT(this); + _priv = this->private; + GF_ASSERT (_priv); + GF_ASSERT(_priv->_db_conn); + + if (op != GF_IPC_TARGET_CTR) + goto wind; + + ret = clear_files_heat (_priv->_db_conn); + + STACK_UNWIND_STRICT (ipc, frame, ret, 0, NULL); + return 0; + + wind: + STACK_WIND (frame, default_ipc_cbk, FIRST_CHILD (this), + FIRST_CHILD (this)->fops->ipc, op, xdata); + return 0; +} + + /******************************************************************************/ int @@ -1596,7 +1626,9 @@ struct xlator_fops fops = { .writev = ctr_writev, .setattr = ctr_setattr, /*read fops*/ - .readv = ctr_readv + .readv = ctr_readv, + /* IPC call*/ + .ipc = ctr_ipc }; struct xlator_cbks cbks = { diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h index 2a1f5203d9b..d6521d26b3d 100644 --- a/xlators/features/changetimerecorder/src/ctr-helper.h +++ b/xlators/features/changetimerecorder/src/ctr-helper.h @@ -22,6 +22,7 @@ #include "iatt.h" #include "glusterfs.h" #include "xlator.h" +#include "defaults.h" #include "logging.h" #include "common-utils.h" #include -- cgit