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

Ensure that the last samples get sent by slave and received by master. #1025

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def stop(self):
def quit(self):
for client in self.clients.all:
self.server.send_to_client(Message("quit", None, client.id))
gevent.sleep(0.5) # wait for final stats report from all slaves
Copy link
Contributor

Choose a reason for hiding this comment

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

This timing seems kind of arbitrary, is there a reason you went with 0.5?

Copy link
Member

Choose a reason for hiding this comment

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

that was my thought also.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is kind of arbitrary, I'm assuming that the latency between master & slave is < .5s.

I tried explicitly waiting for one more event, but ran into issues. It could definitely be done better, but I didnt find a way to do it without adding a significant amount of logic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@aldenpeterson-wf @cgoldberg Any more thoughts? The current behaviour is really bad (missed samples on master), so it needs some kind of fix...

Copy link
Member

Choose a reason for hiding this comment

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

I guess it could track which worker nodes have sent their reports, and then some timeout. But I think this is "good enough" and definitely better than the previous behaviour!

self.greenlet.kill(block=True)

def heartbeat_worker(self):
Expand Down Expand Up @@ -439,16 +440,20 @@ def worker(self):
elif msg.type == "quit":
logger.info("Got quit message from master, shutting down...")
self.stop()
self._send_stats() # send a final report, in case there were any samples not yet reported
self.greenlet.kill(block=True)

def stats_reporter(self):
while True:
data = {}
events.report_to_master.fire(client_id=self.client_id, data=data)
try:
self.client.send(Message("stats", data, self.client_id))
self._send_stats()
except:
logger.error("Connection lost to master server. Aborting...")
break

gevent.sleep(SLAVE_REPORT_INTERVAL)

def _send_stats(self):
data = {}
events.report_to_master.fire(client_id=self.client_id, data=data)
self.client.send(Message("stats", data, self.client_id))