Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parked: Tombstone services before sending updates #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mihaitodor
Copy link

@mihaitodor mihaitodor commented May 11, 2019

Services from expired servers need to be tombstoned before informing the listeners about them, I think :)

In TombstoneOthersServices, we have here a similar call to state.ServiceChanged, where the services get tombstoned first.

LE: There is another problem with missed events due to having a timestamp older than the current state in the receiver, which I tried to fix in 7211a4f, but it's not going to work as is because once the first event is processed by the receiver, the receiver state will contain a timestamp that is newer than all the ChangeEvent.Time of all the other events sent when a server gets expired...

Services from expired servers need to be tombstoned before
informing the listeners about them.
@mihaitodor mihaitodor requested a review from relistan May 11, 2019 22:22
Use the StateChangedEvent.ChangeEvent.Time to figure out if
the current state of the receiver is older than the received
event.

We can't rely on evt.State.LastChanged for this because,
when expiring a server, we get multiple events coming in on
UrlListener.eventChannel and each StateChangedEvent created will
contain a snapshot of the same state. This will make the receiver
process only the first incoming event and drop the rest, because
rcvr.CurrentState.LastChanged = evt.State.LastChanged after the
first event gets processed.
hostname := "grendel"

svcId1 := "deadbeef123"
service1 := service.Service{ID: svcId1, Hostname: hostname}
svcId2 := "ecgtheow"
Copy link
Collaborator

Choose a reason for hiding this comment

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

:)

svc.Tombstone()
state.ServiceChanged(svc, previousStatus, svc.Updated)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You know it occurs to me that maybe we ought to be just doing this outside the loop by capturing the initial state and the final state. No one can process those intermediate changes that fast anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I guess if anything relied on svc.Updated that would break them. Maybe there is some middle ground.

@@ -47,36 +50,57 @@ func Test_prepareCookieJar(t *testing.T) {
}

func Test_Listen(t *testing.T) {
Convey("Listen()", t, func() {
Convey("Listen()", t, func(c C) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I did not know this was a thing. Interesting.

Copy link
Author

Choose a reason for hiding this comment

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

It's handy for testing inside goroutines, although I still haven't gotten around to fixing this bug: smartystreets/goconvey#477

@relistan relistan changed the title Tombstone services before sending updates Parked: Tombstone services before sending updates Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants