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

[autoscaler] Fix potential dead lock in local provider #49909

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
35 changes: 19 additions & 16 deletions python/ray/autoscaler/_private/local/node_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,26 +246,29 @@ def internal_ip(self, node_id):
return socket.gethostbyname(node_id)

def set_node_tags(self, node_id, tags):
with self.state.file_lock:
info = self.state.get()[node_id]
info["tags"].update(tags)
self.state.put(node_id, info)
with self.state.lock:
with self.state.file_lock:
info = self.state.get()[node_id]
info["tags"].update(tags)
self.state.put(node_id, info)

def create_node(self, node_config, tags, count):
"""Creates min(count, currently available) nodes."""
node_type = tags[TAG_RAY_NODE_KIND]
with self.state.file_lock:
workers = self.state.get()
for node_id, info in workers.items():
if info["state"] == "terminated" and (
self.use_coordinator or info["tags"][TAG_RAY_NODE_KIND] == node_type
):
info["tags"] = tags
info["state"] = "running"
self.state.put(node_id, info)
count = count - 1
if count == 0:
return
with self.state.lock:
with self.state.file_lock:
workers = self.state.get()
for node_id, info in workers.items():
if info["state"] == "terminated" and (
self.use_coordinator
or info["tags"][TAG_RAY_NODE_KIND] == node_type
):
info["tags"] = tags
info["state"] = "running"
self.state.put(node_id, info)
count = count - 1
if count == 0:
return

def terminate_node(self, node_id):
workers = self.state.get()
Expand Down