Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

fix(least_connections) change setState order #128

Closed
wants to merge 1 commit into from

Conversation

locao
Copy link
Contributor

@locao locao commented May 6, 2021

Add or remove the address to the available addresses binary heap in the correct order, i.e. setting its available values before making it actually available and, in the same sense, making it unavailable before setting its unavailable values.

Add or remove the address to the available addresses binary heap in the
correct order, i.e. setting its available values before making it
actually available and, in the same sense, making it unavailable before
setting its unavailable values.
@locao locao requested review from Tieske and a user May 6, 2021 19:45
@Tieske
Copy link
Member

Tieske commented May 7, 2021

@locao there is no test showing faulty behavour. Can you explain what this fixes exactly?

@locao
Copy link
Contributor Author

locao commented May 7, 2021

This is pretty much the same as #126. The difference here is that when an address is set as unhealthy disable() is not called, but setAddressState() is.

This tries to avoid a potential race condition, I wasn't able to reproduce the issue in an automated test.

@ghost ghost requested a review from pintsized May 12, 2021 15:05
@@ -137,7 +137,7 @@ function lc:getPeer(cacheOnly, handle, hashValue)
self.binaryHeap:pop()
end
address = self.binaryHeap:peek()
until address == nil or not (handle.failedAddresses or EMPTY)[address]
until address == nil or (not (handle.failedAddresses or EMPTY)[address] and address.host)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like adding complexity when we shouldn't expect address.host to be nil at all. Although I agree, it might stop the crash! My concern though is that this line is already hard to enough to read.

Perhaps instead of this, line 163 should read in a way that is closer to how the other balancers work - they all check for disabled and available before calling getPeer(). So maybe this would do the same job (i.e. prevent the crash even if we don't understand how it happens), and if nothing more would make the balancers more similar?

if address == nil or not address.available or address.disabled then
 ...

@hbagdi
Copy link
Member

hbagdi commented Apr 6, 2023

Closing this due to lack of activity. Please re-open if needed.

@hbagdi hbagdi closed this Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants