You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2014/07/16 05:57:20 UTC
[3/3] git commit: TS-2931: plugin metrics fail after a crash
TS-2931: plugin metrics fail after a crash
If a plugin uses TSStatFindName followed by TSStatCreate, TSStatFindName
can return 0 for all the metric IDs after a traffic_server crash.
This will happen every time with the following conditions:
1. traffic_manager has pulled the stat records from traffic_server
2. traffic_server crashes
When traffic_server comes back up, it pulls the records from
traffic_manager. traffic_manager sends the records including the
rsb_id field. However, RecForceInsert() does not copy the rsb_id
field from the message to the actual record. Subsequent stat lookups
succeed because the stat is registered, but always receive a rsb_id
of 0.
The fix is to ensure that we copy the rsb_id field so that stat
lookups succeed.
(cherry picked from commit d537357da69ee701c7165f0e1f07554e18324e1f)
Conflicts:
CHANGES
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/de2f1174
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/de2f1174
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/de2f1174
Branch: refs/heads/4.2.x
Commit: de2f11742c4e0ae1b4e5ee996dda204c2f59e289
Parents: 19f9417
Author: James Peach <jp...@apache.org>
Authored: Wed Jul 9 13:27:01 2014 -0700
Committer: Phil Sorber <so...@apache.org>
Committed: Tue Jul 15 21:55:57 2014 -0600
----------------------------------------------------------------------
CHANGES | 2 ++
lib/records/P_RecCore.cc | 6 +++---
lib/records/RecCore.cc | 3 +++
proxy/InkAPI.cc | 10 +++++-----
4 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de2f1174/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 6756f04..f0f96e5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 4.2.2
+ *) [TS-2931] Plugin metrics fail after a crash.
+
*) [TS-2776] Core dump inside openssl library
*) [TS-2859] Remove DBG macros to not generate warnings from GCC 4.9.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de2f1174/lib/records/P_RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/P_RecCore.cc b/lib/records/P_RecCore.cc
index b8498e4..ec563a7 100644
--- a/lib/records/P_RecCore.cc
+++ b/lib/records/P_RecCore.cc
@@ -113,7 +113,7 @@ send_push_message()
if (i_am_the_record_owner(r->rec_type)) {
if (r->sync_required & REC_PEER_SYNC_REQUIRED) {
m = RecMessageMarshal_Realloc(m, r);
- r->sync_required = r->sync_required & ~REC_PEER_SYNC_REQUIRED;
+ r->sync_required &= ~REC_PEER_SYNC_REQUIRED;
send_msg = true;
}
}
@@ -157,10 +157,10 @@ send_pull_message(RecMessageT msg_type)
r = &(g_records[i]);
if (i_am_the_record_owner(r->rec_type) ||
(REC_TYPE_IS_STAT(r->rec_type) && !(r->registered)) ||
- (REC_TYPE_IS_STAT(r->rec_type) && !(r->stat_meta.persist_type != RECP_NON_PERSISTENT))) {
+ (REC_TYPE_IS_STAT(r->rec_type) && (r->stat_meta.persist_type == RECP_NON_PERSISTENT))) {
rec_mutex_acquire(&(r->lock));
m = RecMessageMarshal_Realloc(m, r);
- r->sync_required = r->sync_required & ~REC_PEER_SYNC_REQUIRED;
+ r->sync_required &= ~REC_PEER_SYNC_REQUIRED;
rec_mutex_release(&(r->lock));
}
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de2f1174/lib/records/RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index dded7cb..c8fbd6c 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -831,7 +831,10 @@ RecForceInsert(RecRecord * record)
// set the record value
RecDataSet(r->data_type, &(r->data), &(record->data));
RecDataSet(r->data_type, &(r->data_default), &(record->data_default));
+
r->registered = record->registered;
+ r->rsb_id = record->rsb_id;
+
if (REC_TYPE_IS_STAT(r->rec_type)) {
r->stat_meta.persist_type = record->stat_meta.persist_type;
r->stat_meta.data_raw = record->stat_meta.data_raw;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de2f1174/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index a0f752f..f26e6f6 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -85,11 +85,11 @@
_HDR.m_mime = _HDR.m_http->m_fields_impl;
// Globals for new librecords stats
-volatile int top_stat = 0;
-RecRawStatBlock *api_rsb;
+static volatile int api_rsb_index = 0;
+static RecRawStatBlock * api_rsb;
// Globals for the Sessions/Transaction index registry
-volatile int next_argv_index = 0;
+static volatile int next_argv_index = 0;
struct _STATE_ARG_TABLE {
char* name;
@@ -5548,7 +5548,7 @@ TSHttpArgIndexReserve(const char* name, const char* description, int *arg_idx)
{
sdk_assert(sdk_sanity_check_null_ptr(arg_idx) == TS_SUCCESS);
- int volatile ix = ink_atomic_increment(&next_argv_index, 1);
+ int ix = ink_atomic_increment(&next_argv_index, 1);
if (ix < HTTP_SSN_TXN_MAX_USER_ARG) {
state_arg_table[ix].name = ats_strdup(name);
@@ -6638,7 +6638,7 @@ TSCacheScan(TSCont contp, TSCacheKey key, int KB_per_second)
int
TSStatCreate(const char *the_name, TSRecordDataType the_type, TSStatPersistence persist, TSStatSync sync)
{
- int id = ink_atomic_increment(&top_stat, 1);
+ int id = ink_atomic_increment(&api_rsb_index, 1);
RecRawStatSyncCb syncer = RecRawStatSyncCount;
// TODO: This only supports "int" data types at this point, since the "Raw" stats