You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/04/27 23:09:47 UTC
[trafficserver] branch 9.0.x updated (5bd81e8 -> e4c0e9c)
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.
from 5bd81e8 Removes ATS version from gold files
new decd303 Fix lost fragments when update object
new e4c0e9c Patch to catch and invalidate an HTTP asset with negative bytes after cache_seek.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
iocore/cache/CacheRead.cc | 57 +++++++++++++++++++++++++++++++--
iocore/cache/CacheWrite.cc | 4 ++-
iocore/cache/P_CacheInternal.h | 1 +
iocore/cache/test/test_Update_L_to_S.cc | 1 +
iocore/cache/test/test_Update_S_to_L.cc | 1 +
5 files changed, 61 insertions(+), 3 deletions(-)
[trafficserver] 02/02: Patch to catch and invalidate an HTTP asset
with negative bytes after cache_seek.
Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit e4c0e9c27fde765e1fabb5ed96173291bfb38e0e
Author: Brian Olsen <br...@comcast.com>
AuthorDate: Wed Mar 11 17:31:42 2020 +0000
Patch to catch and invalidate an HTTP asset with negative bytes after cache_seek.
(cherry picked from commit a885dc63896e972bcde388c32019d258a6148398)
---
iocore/cache/CacheRead.cc | 57 ++++++++++++++++++++++++++++++++++++++++--
iocore/cache/P_CacheInternal.h | 1 +
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc
index 5dc267b..6c89987 100644
--- a/iocore/cache/CacheRead.cc
+++ b/iocore/cache/CacheRead.cc
@@ -717,8 +717,46 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
bytes = doc->len - doc_pos;
if (is_debug_tag_set("cache_seek")) {
char target_key_str[CRYPTO_HEX_SIZE];
- key.toHexStr(target_key_str);
- Debug("cache_seek", "Read # %d @ %" PRId64 "/%d for %" PRId64, fragment, doc_pos, doc->len, bytes);
+ Debug("cache_seek", "Read # %d @ %" PRId64 "/%d for %" PRId64 " %s", fragment, doc_pos, doc->len, bytes,
+ key.toHexStr(target_key_str));
+ }
+
+ // This shouldn't happen for HTTP assets but it does
+ // occasionally in production. This is a temporary fix
+ // to clean up broken objects until the root cause can
+ // be found. It must be the case that either the fragment
+ // offsets are incorrect or a fragment table isn't being
+ // created when it should be.
+ if (frag_type == CACHE_FRAG_TYPE_HTTP && bytes < 0) {
+ char xt[CRYPTO_HEX_SIZE];
+ char yt[CRYPTO_HEX_SIZE];
+
+ int url_length = 0;
+ char const *url_text = nullptr;
+ if (request.valid()) {
+ url_text = request.url_get()->string_get_ref(&url_length);
+ }
+
+ int64_t prev_frag_size = 0;
+ if (fragment && frags) {
+ prev_frag_size = static_cast<int64_t>(frags[fragment - 1]);
+ }
+
+ Warning("cache_seek range request bug: read %s targ %s - %s frag # %d (prev_frag %" PRId64 ") @ %" PRId64 "/%d for %" PRId64
+ " tot %" PRId64 " url '%.*s'",
+ doc->key.toHexStr(xt), key.toHexStr(yt), f.single_fragment ? "single" : "multi", fragment, prev_frag_size, doc_pos,
+ doc->len, bytes, doc->total_len, url_length, url_text);
+
+ doc->magic = DOC_CORRUPT;
+
+ CACHE_TRY_LOCK(lock, vol->mutex, mutex->thread_holding);
+ if (!lock.is_locked()) {
+ SET_HANDLER(&CacheVC::openReadDirDelete);
+ VC_SCHED_LOCK_RETRY();
+ }
+
+ dir_delete(&earliest_key, vol, &earliest_dir);
+ goto Lerror;
}
}
if (ntodo <= 0) {
@@ -1218,3 +1256,18 @@ Learliest:
SET_HANDLER(&CacheVC::openReadStartEarliest);
return openReadStartEarliest(event, e);
}
+
+/*
+ Handle a directory delete event in case of some detected corruption.
+*/
+int
+CacheVC::openReadDirDelete(int event, Event *e)
+{
+ MUTEX_TRY_LOCK(lock, vol->mutex, mutex->thread_holding);
+ if (!lock.is_locked()) {
+ VC_SCHED_LOCK_RETRY();
+ }
+
+ dir_delete(&earliest_key, vol, &earliest_dir);
+ return calluser(VC_EVENT_ERROR);
+}
diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h
index eb9a72c..3e05f2c 100644
--- a/iocore/cache/P_CacheInternal.h
+++ b/iocore/cache/P_CacheInternal.h
@@ -326,6 +326,7 @@ struct CacheVC : public CacheVConnection {
int openReadFromWriterMain(int event, Event *e);
int openReadFromWriterFailure(int event, Event *);
int openReadChooseWriter(int event, Event *e);
+ int openReadDirDelete(int event, Event *e);
int openWriteCloseDir(int event, Event *e);
int openWriteCloseHeadDone(int event, Event *e);
[trafficserver] 01/02: Fix lost fragments when update object
Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit decd303f27d7e3be6f7817db3d3ea2abcf28191b
Author: scw00 <sc...@apache.org>
AuthorDate: Wed Sep 11 16:30:31 2019 +0800
Fix lost fragments when update object
(cherry picked from commit c35efb328a4052d368924b3d13901ba819d8a96e)
---
iocore/cache/CacheWrite.cc | 4 +++-
iocore/cache/test/test_Update_L_to_S.cc | 1 +
iocore/cache/test/test_Update_S_to_L.cc | 1 +
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc
index b41edcb..944d527 100644
--- a/iocore/cache/CacheWrite.cc
+++ b/iocore/cache/CacheWrite.cc
@@ -105,7 +105,9 @@ CacheVC::updateVector(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
called iff the update is a header only update so the fragment
data should remain valid.
*/
- if (alternate_index >= 0) {
+ // If we are not in header only updating case. Don't copy fragments.
+ if (alternate_index >= 0 &&
+ ((total_len == 0 && alternate.get_frag_offset_count() == 0) && !(f.allow_empty_doc && this->vio.nbytes == 0))) {
alternate.copy_frag_offsets_from(write_vector->get(alternate_index));
}
alternate_index = write_vector->insert(&alternate, alternate_index);
diff --git a/iocore/cache/test/test_Update_L_to_S.cc b/iocore/cache/test/test_Update_L_to_S.cc
index 7ace4ac..9b4ea8e 100644
--- a/iocore/cache/test/test_Update_L_to_S.cc
+++ b/iocore/cache/test/test_Update_L_to_S.cc
@@ -51,6 +51,7 @@ public:
switch (event) {
case CACHE_EVENT_OPEN_READ:
base->do_io_read();
+ REQUIRE(base->vc->alternate.get_frag_offset_count() < 5);
break;
case VC_EVENT_READ_READY:
base->reenable();
diff --git a/iocore/cache/test/test_Update_S_to_L.cc b/iocore/cache/test/test_Update_S_to_L.cc
index def645d..5b0f6d1 100644
--- a/iocore/cache/test/test_Update_S_to_L.cc
+++ b/iocore/cache/test/test_Update_S_to_L.cc
@@ -51,6 +51,7 @@ public:
switch (event) {
case CACHE_EVENT_OPEN_READ:
base->do_io_read();
+ REQUIRE(base->vc->alternate.get_frag_offset_count() > 8);
break;
case VC_EVENT_READ_READY:
base->reenable();