SolidWallOfCode commented on a change in pull request #7485:
URL: https://github.com/apache/trafficserver/pull/7485#discussion_r580319142
##########
File path: proxy/ParentConsistentHash.cc
##########
@@ -231,9 +231,11 @@ ParentConsistentHash::selectParent(bool first_call,
ParentResult *result, Reques
// check if the host is retryable. It's retryable if the retry window
has elapsed
// and the global host status is HOST_STATUS_UP
if (pRec && !pRec->available && host_stat == HOST_STATUS_UP) {
- Debug("parent_select", "Parent.failedAt = %u, retry = %u, xact_start =
%u", (unsigned int)pRec->failedAt,
- (unsigned int)retry_time, (unsigned
int)request_info->xact_start);
- if ((pRec->failedAt + retry_time) < request_info->xact_start) {
+ Debug("parent_select", "Parent.failedAt = %u, retry = %u, retriers =
%d, max_retriers = %u, xact_start = %u",
+ static_cast<unsigned>(pRec->failedAt),
static_cast<unsigned>(retry_time), pRec->retriers, max_retriers,
+ static_cast<unsigned>(request_info->xact_start));
+ if (((pRec->failedAt + retry_time) < request_info->xact_start) &&
(pRec->retriers < max_retriers) &&
+ ink_atomic_increment(&pRec->retriers, 1) < max_retriers) {
Review comment:
There's no point in doing the pre-check because there can still be an
increment on another thread between that and the actual atomic increment. This
merely narrows the window. To be correct, you would do better with something
like
```
if (ink_atomic_increment(&pRec->retriers, 1) < max_retriers) {
// ...
} else {
ink_atomic_increment(&pRec->retriers, -1);
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]