bneradt commented on code in PR #13608:
URL: https://github.com/apache/trafficserver/pull/13608#discussion_r4051029466
##########
src/iocore/cache/unit_tests/test_CacheDir.cc:
##########
@@ -164,78 +164,157 @@ class CacheDirTest : public CacheInit
memset(static_cast<void *>(&dir1), 0, sizeof(dir1));
int s1, b1;
+ // Counted over the segment's rows: the chains are corrupt wherever this
is used.
+ auto count_segment_entries = [&](int seg_index) {
+ Dir *seg_dir = stripe->directory.get_segment(seg_index);
+ int used = 0;
+ for (int b = 0; b < stripe->directory.buckets; b++) {
+ for (int l = 0; l < DIR_DEPTH; l++) {
+ if (dir_offset(dir_bucket_row(dir_bucket(b, seg_dir), l))) {
+ used++;
+ }
+ }
+ }
+ return used;
+ };
+
+ // Give a bucket a fresh chain long enough that a walk has to leave the
bucket's own rows, then loop it.
+ auto corrupt_fresh_chain = [&]() {
+ for (int i = 0; i < 5; i++) {
+ stripe->directory.insert(&key, stripe, &dir1);
+ }
+ dir_corrupt_bucket(dir_bucket(b1, stripe->directory.get_segment(s1)),
s1, stripe);
Review Comment:
[P2] Make the corruption helper reliably create a cycle
When the randomly selected b1 is 0 and dir_corrupt_bucket() chooses l == 0,
e is the segment base. dir_to_offset(e, seg) is then 0, the null-link sentinel,
so dir_set_next(e, 0) truncates the chain instead of creating a cycle. The new
CHECK(!directory.check()), bucket_length == -1, and repair/dirty assertions can
therefore fail intermittently. Other bucket heads have nonzero offsets, so this
is specifically the bucket-0 case (not a 20% failure rate across all buckets).
Please select a non-head entry for the self-loop, or deterministically loop the
second entry; the helper always inserts enough entries for that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]