masaori335 opened a new pull request, #13608:
URL: https://github.com/apache/trafficserver/pull/13608

   The loop protection in probe/overwrite/remove/dir_clean_bucket sat behind 
LOOP_CHECK_MODE, which is commented out and not settable from CMake, so 
production builds walked bucket chains unbounded. A cycle in dir_next spins an 
event thread while it holds the stripe mutex. 
   
   I have never seen this infinite loop in production. This is defensive change 
and cleanup of the `LOOP_CHECK_MODE`.
   
   Directory::max_bucket_depth() is the bound, (DIR_DEPTH - 1) * buckets
   + 1: init_segment() frees rows 1..DIR_DEPTH-1 of every bucket onto the free 
list and never row 0, so one chain holds at most every free entry of the 
segment plus its own head. Exceeding it proves a cycle, so no exact check is 
needed at the trigger. bucket_length() capped at a hardcoded 100 instead, below 
the longest legitimate chain, so a chain over that would make check_segment() 
report corruption and Stripe::_shm_directory_is_valid() reject a healthy shared 
memory attach.
   
   Readers report and move on, writers repair. probe() throttles its report 
because it does not repair, so the loop lives until a writer clears it and 
every lookup that hashes to the bucket lands on the same trigger. insert()'s 
tail walk is the only chain walk it makes, so that is where a writer meets a 
cycle, and stopping at the cap linked the new entry into the cycle.
   
   Stripe::dir_check() had no cap at all and wrote chain_tag[] once per step, 
so a cycle ran off the end of a 65536-entry stack array. It now stops at the 
bound, and at the first revisited entry rather than printing a cycle line per 
step. check_bucket_not_contains(), an unbounded walk with no caller since the 
2009 import, is deleted.


-- 
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]

Reply via email to