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/09/22 01:25:16 UTC
trafficserver git commit: [TS-3927] Fix Cache Open Write Retries and
make the setting overridable.
Repository: trafficserver
Updated Branches:
refs/heads/master fe4ee3664 -> 1614f4f28
[TS-3927] Fix Cache Open Write Retries and make the setting overridable.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1614f4f2
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1614f4f2
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1614f4f2
Branch: refs/heads/master
Commit: 1614f4f284a9ff63f19808d5eb34e8cd17cf2ad9
Parents: fe4ee36
Author: Sudheer Vinukonda <su...@yahoo-inc.com>
Authored: Mon Sep 21 23:24:39 2015 +0000
Committer: Sudheer Vinukonda <su...@yahoo-inc.com>
Committed: Mon Sep 21 23:24:39 2015 +0000
----------------------------------------------------------------------
lib/ts/apidefs.h.in | 1 +
.../experimental/ts_lua/ts_lua_http_config.c | 7 +++-
proxy/InkAPI.cc | 6 ++++
proxy/InkAPITest.cc | 3 +-
proxy/http/HttpCacheSM.cc | 34 +++++++++++++++++---
proxy/http/HttpConfig.cc | 4 +--
proxy/http/HttpConfig.h | 22 ++++++-------
7 files changed, 57 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1614f4f2/lib/ts/apidefs.h.in
----------------------------------------------------------------------
diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
index 332d53f..6dba244 100644
--- a/lib/ts/apidefs.h.in
+++ b/lib/ts/apidefs.h.in
@@ -691,6 +691,7 @@ typedef enum {
TS_CONFIG_HTTP_CACHE_OPEN_WRITE_FAIL_ACTION,
TS_CONFIG_HTTP_ENABLE_REDIRECTION,
TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS,
+ TS_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES,
TS_CONFIG_LAST_ENTRY
} TSOverridableConfigKey;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1614f4f2/plugins/experimental/ts_lua/ts_lua_http_config.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http_config.c b/plugins/experimental/ts_lua/ts_lua_http_config.c
index 0f07c26..b87baba 100644
--- a/plugins/experimental/ts_lua/ts_lua_http_config.c
+++ b/plugins/experimental/ts_lua/ts_lua_http_config.c
@@ -86,6 +86,9 @@ typedef enum {
TS_LUA_CONFIG_OPEN_WRITE_FAIL_ACTION = TS_CONFIG_HTTP_CACHE_OPEN_WRITE_FAIL_ACTION,
TS_LUA_CONFIG_HTTP_ENABLE_REDIRECTION = TS_CONFIG_HTTP_ENABLE_REDIRECTION,
TS_LUA_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS = TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS,
+ TS_LUA_CONFIG_HTTP_CACHE_OPEN_READ_RETRY_TIME = TS_CONFIG_HTTP_CACHE_OPEN_READ_RETRY_TIME,
+ TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_READ_RETRIES = TS_CONFIG_HTTP_CACHE_MAX_OPEN_READ_RETRIES,
+ TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES = TS_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES,
TS_LUA_CONFIG_LAST_ENTRY = TS_CONFIG_LAST_ENTRY,
} TSLuaOverridableConfigKey;
@@ -148,7 +151,9 @@ ts_lua_var_item ts_lua_http_config_vars[] = {
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_NET_SOCK_PACKET_TOS_OUT), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_SLOW_LOG_THRESHOLD),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_BODY_FACTORY_TEMPLATE_BASE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_OPEN_WRITE_FAIL_ACTION),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_ENABLE_REDIRECTION), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS),
- TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_OPEN_READ_RETRY_TIME),
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_READ_RETRIES),
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
};
ts_lua_var_item ts_lua_http_timeout_vars[] = {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1614f4f2/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index a9d70a6..2c6a946 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7938,6 +7938,10 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr
typ = OVERRIDABLE_TYPE_INT;
ret = &overridableHttpConfig->max_cache_open_read_retries;
break;
+ case TS_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES:
+ typ = OVERRIDABLE_TYPE_INT;
+ ret = &overridableHttpConfig->max_cache_open_write_retries;
+ break;
case TS_CONFIG_HTTP_CACHE_OPEN_WRITE_FAIL_ACTION:
typ = OVERRIDABLE_TYPE_INT;
ret = &overridableHttpConfig->cache_open_write_fail_action;
@@ -8486,6 +8490,8 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf,
case 's':
if (!strncmp(name, "proxy.config.http.connect_attempts_max_retries", length))
cnf = TS_CONFIG_HTTP_CONNECT_ATTEMPTS_MAX_RETRIES;
+ else if (!strncmp(name, "proxy.config.http.cache.max_open_write_retries", length))
+ cnf = TS_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES;
break;
case 't':
if (!strncmp(name, "proxy.config.http.forward.proxy_auth_to_parent", length))
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1614f4f2/proxy/InkAPITest.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index ffba7d9..fae5f9e 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -7239,7 +7239,8 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = {
"proxy.config.http.post.check.content_length.enabled", "proxy.config.http.global_user_agent_header",
"proxy.config.http.auth_server_session_private", "proxy.config.http.slow.log.threshold", "proxy.config.http.cache.generation",
"proxy.config.body_factory.template_base", "proxy.config.http.cache.open_write_fail_action",
- "proxy.config.http.redirection_enabled", "proxy.config.http.number_of_redirections"};
+ "proxy.config.http.redirection_enabled", "proxy.config.http.number_of_redirections",
+ "proxy.config.http.cache.max_open_write_retries"};
REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus)
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1614f4f2/proxy/http/HttpCacheSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpCacheSM.cc b/proxy/http/HttpCacheSM.cc
index c259b38..64e2650 100644
--- a/proxy/http/HttpCacheSM.cc
+++ b/proxy/http/HttpCacheSM.cc
@@ -172,10 +172,33 @@ HttpCacheSM::state_cache_open_write(int event, void *data)
break;
case CACHE_EVENT_OPEN_WRITE_FAILED:
- // The cache is hosed or full or something.
- // Forward the failure to the main sm
- open_write_cb = true;
- master_sm->handleEvent(event, data);
+ if (open_write_tries <= master_sm->t_state.txn_conf->max_cache_open_write_retries) {
+ // Retry open write;
+ open_write_cb = false;
+ do_schedule_in();
+ } else {
+ // The cache is hosed or full or something.
+ // Forward the failure to the main sm
+ Debug("http_cache", "[%" PRId64 "] [state_cache_open_write] cache open write failure %d. "
+ "done retrying...",
+ master_sm->sm_id, open_write_tries);
+ open_write_cb = true;
+ master_sm->handleEvent(event, data);
+ }
+ break;
+
+ case EVENT_INTERVAL:
+ // Retry the cache open write if the number retries is less
+ // than or equal to the max number of open write retries
+ ink_assert(open_write_tries <= master_sm->t_state.txn_conf->max_cache_open_write_retries);
+ Debug("http_cache", "[%" PRId64 "] [state_cache_open_write] cache open write failure %d. "
+ "retrying cache open write...",
+ master_sm->sm_id, open_write_tries);
+
+ open_write(
+ &cache_key, lookup_url, read_request_hdr, master_sm->t_state.cache_info.object_read,
+ (time_t)((master_sm->t_state.cache_control.pin_in_cache_for < 0) ? 0 : master_sm->t_state.cache_control.pin_in_cache_for),
+ retry_write, false);
break;
default:
@@ -286,6 +309,7 @@ HttpCacheSM::open_write(const HttpCacheKey *key, URL *url, HTTPHdr *request, Cac
ink_assert(request == read_request_hdr || read_request_hdr == NULL);
this->lookup_url = url;
this->read_request_hdr = request;
+ cache_key = *key;
// Make sure we are not stuck in a loop where the write
// fails but the retry read succeeds causing to issue
@@ -293,7 +317,7 @@ HttpCacheSM::open_write(const HttpCacheKey *key, URL *url, HTTPHdr *request, Cac
// that must be revalidated every time)
// Changed by YTS Team, yamsat Plugin
if (open_write_tries > master_sm->redirection_tries &&
- open_write_tries > master_sm->t_state.http_config_param->max_cache_open_write_retries) {
+ open_write_tries > master_sm->t_state.txn_conf->max_cache_open_write_retries) {
master_sm->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-ECACHE_DOC_BUSY);
return ACTION_RESULT_DONE;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1614f4f2/proxy/http/HttpConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 96fe448..6cc56c9 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -1023,7 +1023,7 @@ HttpConfig::startup()
HttpEstablishStaticConfigLongLong(c.oride.cache_generation_number, "proxy.config.http.cache.generation");
// open write failure retries
- HttpEstablishStaticConfigLongLong(c.max_cache_open_write_retries, "proxy.config.http.cache.max_open_write_retries");
+ HttpEstablishStaticConfigLongLong(c.oride.max_cache_open_write_retries, "proxy.config.http.cache.max_open_write_retries");
HttpEstablishStaticConfigByte(c.oride.cache_http, "proxy.config.http.cache.http");
HttpEstablishStaticConfigByte(c.oride.cache_cluster_cache_local, "proxy.config.http.cache.cluster_cache_local");
@@ -1286,7 +1286,7 @@ HttpConfig::reconfigure()
params->oride.cache_generation_number = m_master.oride.cache_generation_number;
// open write failure retries
- params->max_cache_open_write_retries = m_master.max_cache_open_write_retries;
+ params->oride.max_cache_open_write_retries = m_master.oride.max_cache_open_write_retries;
params->oride.cache_http = INT_TO_BOOL(m_master.oride.cache_http);
params->oride.cache_cluster_cache_local = INT_TO_BOOL(m_master.oride.cache_cluster_cache_local);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1614f4f2/proxy/http/HttpConfig.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index 62cc4a4..f6fdda6 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -382,8 +382,8 @@ struct OverridableHttpConfigParams {
connect_attempts_max_retries_dead_server(3), connect_attempts_rr_retries(3), connect_attempts_timeout(30),
post_connect_attempts_timeout(1800), down_server_timeout(300), client_abort_threshold(10), freshness_fuzz_time(240),
freshness_fuzz_min_time(0), max_cache_open_read_retries(-1), cache_open_read_retry_time(10), cache_generation_number(-1),
- background_fill_active_timeout(60), http_chunking_size(4096), flow_high_water_mark(0), flow_low_water_mark(0),
- default_buffer_size_index(8), default_buffer_water_mark(32768), slow_log_threshold(0),
+ max_cache_open_write_retries(1), background_fill_active_timeout(60), http_chunking_size(4096), flow_high_water_mark(0),
+ flow_low_water_mark(0), default_buffer_size_index(8), default_buffer_water_mark(32768), slow_log_threshold(0),
// Strings / floats must come last
body_factory_template_base(NULL), body_factory_template_base_len(0), proxy_response_server_string(NULL),
@@ -549,6 +549,9 @@ struct OverridableHttpConfigParams {
MgmtInt cache_open_read_retry_time; // time is in mseconds
MgmtInt cache_generation_number;
+ // open write failure retries.
+ MgmtInt max_cache_open_write_retries;
+
MgmtInt background_fill_active_timeout;
MgmtInt http_chunking_size; // Maximum chunk size for chunked output.
@@ -684,9 +687,6 @@ public:
char *cache_vary_default_images;
char *cache_vary_default_other;
- // open write failure retries.
- MgmtInt max_cache_open_write_retries;
-
///////////////////
// cache control //
///////////////////
@@ -853,12 +853,12 @@ inline HttpConfigParams::HttpConfigParams()
session_auth_cache_keep_alive_enabled(1), transaction_active_timeout_in(900), accept_no_activity_timeout(120),
parent_connect_attempts(4), per_parent_connect_attempts(2), parent_connect_timeout(30), anonymize_other_header_list(NULL),
enable_http_stats(1), icp_enabled(0), stale_icp_enabled(0), cache_vary_default_text(NULL), cache_vary_default_images(NULL),
- cache_vary_default_other(NULL), max_cache_open_write_retries(1), cache_enable_default_vary_headers(0), cache_post_method(0),
- connect_ports_string(NULL), connect_ports(NULL), push_method_enabled(0), referer_filter_enabled(0), referer_format_redirect(0),
- reverse_proxy_enabled(0), url_remap_required(1), record_cop_page(0), errors_log_error_pages(1), enable_http_info(0),
- cluster_time_delta(0), redirection_host_no_port(1), post_copy_size(2048), ignore_accept_mismatch(0),
- ignore_accept_language_mismatch(0), ignore_accept_encoding_mismatch(0), ignore_accept_charset_mismatch(0),
- send_100_continue_response(0), disallow_post_100_continue(0), parser_allow_non_http(1), max_post_size(0),
+ cache_vary_default_other(NULL), cache_enable_default_vary_headers(0), cache_post_method(0), connect_ports_string(NULL),
+ connect_ports(NULL), push_method_enabled(0), referer_filter_enabled(0), referer_format_redirect(0), reverse_proxy_enabled(0),
+ url_remap_required(1), record_cop_page(0), errors_log_error_pages(1), enable_http_info(0), cluster_time_delta(0),
+ redirection_host_no_port(1), post_copy_size(2048), ignore_accept_mismatch(0), ignore_accept_language_mismatch(0),
+ ignore_accept_encoding_mismatch(0), ignore_accept_charset_mismatch(0), send_100_continue_response(0),
+ disallow_post_100_continue(0), parser_allow_non_http(1), max_post_size(0),
server_session_sharing_pool(TS_SERVER_SESSION_SHARING_POOL_THREAD), synthetic_port(0)
{
}