Skip to content

WIP: Move heartbeat to long running connection - #2854

Closed
pacman82 wants to merge 3 commits into
dask:masterfrom
pacman82:move-heartbeat-to-long-running-connection
Closed

pacman82 wants to merge 3 commits into
dask:masterfrom
pacman82:move-heartbeat-to-long-running-connection

Conversation

@pacman82

Copy link
Copy Markdown

Is this enough to address #2524

@mrocklin

Copy link
Copy Markdown
Member

I don't think so? Perhaps you can say more about what you were intending to do here

@pacman82 pacman82 changed the title Move heartbeat to long running connection WIP: Move heartbeat to long running connection Jul 25, 2019
@lr4d

lr4d commented Jul 29, 2019

Copy link
Copy Markdown
Contributor

This should address #2525 and #2524 (PR #2845 can probably be closed, as this builds on top of it).

The first commit removes the reconnection trigger when the worker receives status=missing to prevent the race condition of #2525 .

The second commit moves the heartbeat to the long running connection between worker and scheduler.
I have tested this and HAProxy no longer kills the connection between worker and scheduler after an hour, as described originally in #2524 .

Some adjustments had to be made to the tests so that they would wait for the heartbeat response from the scheduler.

@mrocklin what do you think?

@mrocklin

Copy link
Copy Markdown
Member

In principle it seems fine

Some adjustments had to be made to the tests so that they would wait for the heartbeat response from the scheduler.

These adjustments are, I think, too invasive. We wouldn't expect a beginner dev to know how to add these if they were making a new test on something as unrelated as dashboard code.

As an alternative, perhaps this? #2525 (comment)

@lr4d

lr4d commented Jul 30, 2019

Copy link
Copy Markdown
Contributor

These adjustments are, I think, too invasive.

I am not too comfortable with it, either. It can be simplified however, perhaps using something like:

def wait_for_heartbeat(scheduler, *workers):
    [...]

and calling wait_for_heartbeat(s, a, b) instead of this (current) code block:

    bs = s.stream_comms[a.address]
    init = bs.batch_count
    yield [a.heartbeat(), b.heartbeat()]
    yield gen.sleep(bs.interval)
    yield gen.sleep(bs.interval)
    assert bs.batch_count > init

I'd appreciate suggestions in this regard.

Regarding the alternative you propose, it would probably fix the issue, but @pacman82 and I moved the heartbeat to the long running connection as we thought adding another route which would function as keep-alive would increase complexity while not adding more value

@lr4d

lr4d commented Jul 30, 2019

Copy link
Copy Markdown
Contributor

I've updated the last commit, now it only replaces the line yield [a.heartbeat(), b.heartbeat()] in the tests for yield wait_for_heartbeat(s, a, b). I think this should allow new developers to still understand and be able to create dashboard tests.

@mrocklin

Copy link
Copy Markdown
Member

I've updated the last commit, now it only replaces the line yield [a.heartbeat(), b.heartbeat()] in the tests for yield wait_for_heartbeat(s, a, b). I think this should allow new developers to still understand and be able to create dashboard tests.

Previously we could expect a heartbeat to have occurred before a worker had started. I don't think that we should relax this condition. My concern isn't only on dashboard tests, but on the full system. This seems like a regression to me.

@mrocklin

Copy link
Copy Markdown
Member

Regarding the alternative you propose, it would probably fix the issue, but @pacman82 and I moved the heartbeat to the long running connection as we thought adding another route which would function as keep-alive would increase complexity while not adding more value

I agree that ideally heartbeats should play this role, but the complexity of #2907 seems to be much less than the complexity that we've had to go through here.

@lr4d

lr4d commented Jul 31, 2019

Copy link
Copy Markdown
Contributor

Previously we could expect a heartbeat to have occurred before a worker had started. I don't think that we should relax this condition. My concern isn't only on dashboard tests, but on the full system. This seems like a regression to me.

What's the rationale behind this?

@lr4d

lr4d commented Jul 31, 2019

Copy link
Copy Markdown
Contributor

the complexity of #2907 seems to be much less than the complexity that we've had to go through here

Is this because of the testing code?
The reason I like this approach is because it looks to me like #2907 increases architectural complexity and maintainability relative to this PR

@mrocklin

Copy link
Copy Markdown
Member

What's the rationale behind this?

I'm not sure that this was intentional originally, but the fact that some tests failed when we took this away means that some functionality implicitly depended on it. I suspect that functionality outside of our test suite also depends on it.

Looking at the tests it seems like the scheduler would like to have metrics from workers as soon as they arrive?

@mrocklin

Copy link
Copy Markdown
Member

The reason I like this approach is because it looks to me like #2907 increases architectural complexity and maintainability relative to this PR

That PR is, from my perspective, very simple to maintain. Adding new routes is cheap (especially if they don't do anything). Adding PeriodicCallbacks is cheap. Changing how we do heartbeats is more uncertain and more likely to have unexpected consequences.

@lr4d

lr4d commented Jul 31, 2019

Copy link
Copy Markdown
Contributor

I'm not sure that this was intentional originally, but the fact that some tests failed when we took this away means that some functionality implicitly depended on it. I suspect that functionality outside of our test suite also depends on it.

Looking at the tests it seems like the scheduler would like to have metrics from workers as soon as they arrive?

I realized that previously the heartbeat method of a worker would await the message from the scheduler. This is causing the need for adjustments to tests as the heartbeat has not yet fully completed after yield worker.heartbeat() is executed.

@lr4d

lr4d commented Jul 31, 2019

Copy link
Copy Markdown
Contributor

Essentially, though, the heartbeat works in the same way, except that the communication channel is different and that the heartbeat waits for worker.batched_stream.interval before actually relaying the message to the scheduler when worker.heartbeat is executed (this is the logic of batched_stream.send).

The difficult thing (for me, at least) in this case is to wait for the heartbeat to have completed: previously a simple yield worker.heartbeat() would suffice and the heartbeat would have arrived at the scheduler and received a succesful response. With the current implementation, one would ideally wait for worker.heartbeat_response but since this a stream_handler, I have not yet figured out a way to do so

@mrocklin

Copy link
Copy Markdown
Member

Do the other solutions work? If so, I'm inclined just to go with them if that's ok.

@lr4d

lr4d commented Jul 31, 2019

Copy link
Copy Markdown
Contributor

I didn't yet test it for the HAProxy situation but I'm pretty sure they will. I respect your decision on this matter.

@martindurant

Copy link
Copy Markdown
Member

@lr4d , @pacman82 : I have not been following the conversation here, just a gentle ping to ask where you think things currently stand

@mrocklin

mrocklin commented Aug 5, 2019

Copy link
Copy Markdown
Member

This was resolved in another PR. Closing. Thanks @pacman82 for raising this. Thanks @martindurant for the nudge.

@mrocklin mrocklin closed this Aug 5, 2019
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.

4 participants