Repository: trafficserver Updated Branches: refs/heads/master 6ae8753f1 -> 086bf328c
[TS-3767]: Add new config to limit the read-while-writer retries. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3c57dc6e Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3c57dc6e Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3c57dc6e Branch: refs/heads/master Commit: 3c57dc6e6f888d2fa6ca92bb2d6953016024f730 Parents: 6ae8753 Author: Sudheer Vinukonda <[email protected]> Authored: Tue Jul 14 20:34:20 2015 +0000 Committer: Sudheer Vinukonda <[email protected]> Committed: Tue Jul 14 20:35:43 2015 +0000 ---------------------------------------------------------------------- iocore/cache/Cache.cc | 4 ++++ iocore/cache/CacheRead.cc | 16 +++++++++++++--- iocore/cache/P_CacheInternal.h | 11 +++-------- mgmt/RecordsConfig.cc | 2 ++ 4 files changed, 22 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3c57dc6e/iocore/cache/Cache.cc ---------------------------------------------------------------------- diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc index 330aedd..aba1d0c 100644 --- a/iocore/cache/Cache.cc +++ b/iocore/cache/Cache.cc @@ -80,6 +80,7 @@ int cache_config_enable_checksum = 0; int cache_config_alt_rewrite_max_size = 4096; int cache_config_read_while_writer = 0; int cache_config_mutex_retry_delay = 2; +int cache_read_while_writer_retry_delay = 50; int cache_config_read_while_writer_max_retries = 10; #ifdef HTTP_CACHE static int enable_cache_empty_http_doc = 0; @@ -3191,6 +3192,9 @@ ink_cache_init(ModuleVersion v) REC_EstablishStaticConfigInt32(cache_config_read_while_writer_max_retries, "proxy.config.cache.read_while_writer.max_retries"); Debug("cache_init", "proxy.config.cache.read_while_writer.max_retries = %d", cache_config_read_while_writer_max_retries); + REC_EstablishStaticConfigInt32(cache_read_while_writer_retry_delay, "proxy.config.cache.read_while_writer_retry_delay"); + Debug("cache_init", "proxy.config.cache.read_while_writer_retry_delay = %dms", cache_read_while_writer_retry_delay); + REC_EstablishStaticConfigInt32(cache_config_hit_evacuate_percent, "proxy.config.cache.hit_evacuate_percent"); Debug("cache_init", "proxy.config.cache.hit_evacuate_percent = %d", cache_config_hit_evacuate_percent); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3c57dc6e/iocore/cache/CacheRead.cc ---------------------------------------------------------------------- diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc index c617ee4..8304a9a 100644 --- a/iocore/cache/CacheRead.cc +++ b/iocore/cache/CacheRead.cc @@ -336,7 +336,11 @@ CacheVC::openReadFromWriter(int event, Event *e) return openReadStartHead(event, e); } else if (ret == EVENT_CONT) { ink_assert(!write_vc); - VC_SCHED_WRITER_RETRY(); + if (writer_lock_retry < cache_config_read_while_writer_max_retries) { + VC_SCHED_WRITER_RETRY(); + } else { + return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event *)-err); + } } else ink_assert(write_vc); } else { @@ -587,8 +591,14 @@ CacheVC::openReadReadDone(int event, Event *e) DDebug("cache_read_agg", "%p: key: %X ReadRead writer aborted: %d", this, first_key.slice32(1), (int)vio.ndone); goto Lerror; } - DDebug("cache_read_agg", "%p: key: %X ReadRead retrying: %d", this, first_key.slice32(1), (int)vio.ndone); - VC_SCHED_WRITER_RETRY(); // wait for writer + if (writer_lock_retry < cache_config_read_while_writer_max_retries) { + DDebug("cache_read_agg", "%p: key: %X ReadRead retrying: %d", this, first_key.slice32(1), (int)vio.ndone); + VC_SCHED_WRITER_RETRY(); // wait for writer + } else { + DDebug("cache_read_agg", "%p: key: %X ReadRead retries exhausted, bailing..: %d", this, first_key.slice32(1), + (int)vio.ndone); + goto Ldone; + } } // fall through for truncated documents } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3c57dc6e/iocore/cache/P_CacheInternal.h ---------------------------------------------------------------------- diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h index eb3a161..4f91dbc 100644 --- a/iocore/cache/P_CacheInternal.h +++ b/iocore/cache/P_CacheInternal.h @@ -59,8 +59,6 @@ struct EvacuationBlock; #endif #define AIO_SOFT_FAILURE -100000 -// retry read from writer delay -#define WRITER_RETRY_DELAY HRTIME_MSECONDS(50) #ifndef CACHE_LOCK_FAIL_RATE #define CACHE_TRY_LOCK(_l, _m, _t) MUTEX_TRY_LOCK(_l, _m, _t) @@ -96,13 +94,9 @@ struct EvacuationBlock; do { \ ink_assert(!trigger); \ writer_lock_retry++; \ - ink_hrtime _t = WRITER_RETRY_DELAY; \ + ink_hrtime _t = cache_read_while_writer_retry_delay; \ if (writer_lock_retry > 2) \ - _t = WRITER_RETRY_DELAY * 2; \ - else if (writer_lock_retry > 5) \ - _t = WRITER_RETRY_DELAY * 10; \ - else if (writer_lock_retry > 10) \ - _t = WRITER_RETRY_DELAY * 100; \ + _t = cache_read_while_writer_retry_delay * 2; \ trigger = mutex->thread_holding->schedule_in_local(this, _t); \ return EVENT_CONT; \ } while (0) @@ -221,6 +215,7 @@ extern int cache_config_hit_evacuate_size_limit; extern int cache_config_force_sector_size; extern int cache_config_target_fragment_size; extern int cache_config_mutex_retry_delay; +extern int cache_read_while_writer_retry_delay; extern int cache_config_read_while_writer_max_retries; // CacheVC http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3c57dc6e/mgmt/RecordsConfig.cc ---------------------------------------------------------------------- diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 4d847b0..2f37b36 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -966,6 +966,8 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.cache.read_while_writer.max_retries", RECD_INT, "10", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL} , + {RECT_CONFIG, "proxy.config.cache.read_while_writer_retry_delay", RECD_INT, "50", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL} + , //############################################################################## //#
