You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by su...@apache.org on 2015/07/14 22:49:34 UTC

[1/2] trafficserver git commit: [TS-3767]: Add new config to limit the read-while-writer retries.

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 <su...@yahoo-inc.com>
Authored: Tue Jul 14 20:34:20 2015 +0000
Committer: Sudheer Vinukonda <su...@yahoo-inc.com>
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}
+  ,
 
   //##############################################################################
   //#


[2/2] trafficserver git commit: [TS-3767]: Change the config name to be consistent with the other setting and add docs.

Posted by su...@apache.org.
[TS-3767]: Change the config name to be consistent with the other setting  and add docs.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/086bf328
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/086bf328
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/086bf328

Branch: refs/heads/master
Commit: 086bf328c2e19f08b84b75da484f213cbe5c6357
Parents: 3c57dc6
Author: Sudheer Vinukonda <su...@yahoo-inc.com>
Authored: Tue Jul 14 20:48:24 2015 +0000
Committer: Sudheer Vinukonda <su...@yahoo-inc.com>
Committed: Tue Jul 14 20:48:24 2015 +0000

----------------------------------------------------------------------
 doc/admin/http-proxy-caching.en.rst               |  9 ++++++---
 doc/reference/configuration/records.config.en.rst | 16 +++++++++++++---
 iocore/cache/Cache.cc                             |  4 ++--
 mgmt/RecordsConfig.cc                             |  2 +-
 4 files changed, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/086bf328/doc/admin/http-proxy-caching.en.rst
----------------------------------------------------------------------
diff --git a/doc/admin/http-proxy-caching.en.rst b/doc/admin/http-proxy-caching.en.rst
index 05a93d5..9c86609 100644
--- a/doc/admin/http-proxy-caching.en.rst
+++ b/doc/admin/http-proxy-caching.en.rst
@@ -784,12 +784,15 @@ All four configurations are required, for the following reasons:
 Once these are enabled, you have something that is very close, but not quite
 the same, to Squid's Collapsed Forwarding.
 
-In addition to the above settings, the setting :ts:cv:`proxy.config.cache.read_while_writer.max_retries`
-allows to control the number of retries (100msec each) TS attempts to trigger
-read-while-writer until the download of first fragment of the object is completed::
+In addition to the above settings, the settings :ts:cv:`proxy.config.cache.read_while_writer.max_retries`
+and :ts:cv:`proxy.config.cache.read_while_writer.delay` allow to control the number
+of retries TS attempts to trigger read-while-writer until the download of first fragment
+of the object is completed::
 
     CONFIG proxy.config.cache.read_while_writer.max_retries INT 10
 
+    CONFIG proxy.config.cache.read_while_writer.delay INT 50
+
 .. _fuzzy-revalidation:
 
 Fuzzy Revalidation

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/086bf328/doc/reference/configuration/records.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/configuration/records.config.en.rst b/doc/reference/configuration/records.config.en.rst
index 6baf5c3..5746a03 100644
--- a/doc/reference/configuration/records.config.en.rst
+++ b/doc/reference/configuration/records.config.en.rst
@@ -1288,9 +1288,19 @@ Cache Control
 .. ts:cv:: CONFIG proxy.config.cache.read_while_writer.max_retries INT 10
    :reloadable:
 
-   Specifies how many retries (100msec each) trafficserver attempts to trigger read_while_writer
-   on failing to obtain the write VC mutex or until the first fragment is downloaded for the
-   object being downloaded.
+   Specifies how many retries trafficserver attempts to trigger read_while_writer on failing
+   to obtain the write VC mutex or until the first fragment is downloaded for the
+   object being downloaded. The retry duration is specified using the setting
+   ts:cv:`proxy.config.cache.read_while_writer.delay`
+
+.. ts:cv:: CONFIG proxy.config.cache.read_while_writer.delay INT 50
+   :reloadable:
+
+   Specifies the delay in msec, trafficserver waits to reattempt read_while_writer
+   on failing to obtain the write VC mutex or until the first fragment is downloaded
+   for the object being downloaded. Note that trafficserver implements a progressive
+   delay in reattempting, by doubling the configured duration from the third reattempt
+   onwards.
 
 .. ts:cv:: CONFIG proxy.config.cache.force_sector_size INT 0
    :reloadable:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/086bf328/iocore/cache/Cache.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index aba1d0c..bfc5f84 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -3192,8 +3192,8 @@ 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_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/086bf328/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 2f37b36..7ee3154 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -966,7 +966,7 @@ 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}
+  {RECT_CONFIG, "proxy.config.cache.read_while_writer_retry.delay", RECD_INT, "50", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
 
   //##############################################################################