Skip to content

Commit

Permalink
[finagle-core] Fix for DeadlineFilter takes rejectWithdrawal regardle…
Browse files Browse the repository at this point in the history
…ss of passed Deadline

Problem
DeadlineFilter takes rejectWithdrawal regardless of passed Deadline
#936

Solution
Withdraw tokens only if the deadline has passed

Closes #936

Differential Revision: https://phabricator.twitter.biz/D1120240
  • Loading branch information
mbezoyan authored and jenkins committed Jan 16, 2024
1 parent d905fa7 commit 51b701e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Note that ``PHAB_ID=#`` and ``RB_ID=#`` correspond to associated messages in com
Unreleased
----------

Bug Fixes
~~~~~~~~~~

* finagle-core: Fix for DeadlineFilter takes rejectWithdrawal regardless of passed Deadline. ``PHAB_ID=D1120240``

23.11.0
-------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ class DeadlineFilter[Req, Rep](

val now = Time.now
val difference: Duration = deadline - now
val reject = rejectBucket.tryGet(rejectWithdrawal)

trace(tracing, deadline, difference, reject)

// If the difference is negative, we've exceeded the deadline
if (difference.inMillis < 0l) {
Expand All @@ -291,6 +288,8 @@ class DeadlineFilter[Req, Rep](
expiredTimeStat.add(exceeded.inMillis)

// There are enough tokens to reject the request
val reject = rejectBucket.tryGet(rejectWithdrawal)
trace(tracing, deadline, difference, reject)
if (reject) {
rejectedCounter.incr()
if (isDarkMode)
Expand All @@ -304,6 +303,7 @@ class DeadlineFilter[Req, Rep](
service(request)
}
} else {
trace(tracing, deadline, difference, false)
rejectBucket.put(serviceDeposit)
val remaining = difference
remainingTimeStat.add(remaining.inMillis)
Expand Down

0 comments on commit 51b701e

Please sign in to comment.