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

[Serve] Add hash function of RunningReplicaInfo #32772

Conversation

sihanwang41
Copy link
Contributor

@sihanwang41 sihanwang41 commented Feb 23, 2023

Why are these changes needed?

When the longpoll client timeout happens, the all internal objects will be cleaned up. The longpoll client will try to poll again. When this happens, longpoll client will receive another object which having same information but different object id (ActorHandle) from the controller.
Then after compute_iterable_delta is called, it will replace the same replica in in_flight_queries, and cause router clean up ongoing request_ref, and keep assigning new request to the replica, which will break the max_concurrent_queries parameter.

Related issue number

Closes #32652

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@sihanwang41 sihanwang41 force-pushed the autoscaling_fix_with_RunningReplicaInfo branch from 0c64878 to 972a1ac Compare February 23, 2023 17:49
@sihanwang41 sihanwang41 changed the title [Serve] Use actor_id when compare RunningReplicaInfo [Serve] Add hash function of RunningReplicaInfo Feb 23, 2023
@sihanwang41 sihanwang41 force-pushed the autoscaling_fix_with_RunningReplicaInfo branch from 972a1ac to fae27a1 Compare February 23, 2023 18:15
@sihanwang41 sihanwang41 marked this pull request as ready for review February 23, 2023 18:53
@sihanwang41 sihanwang41 force-pushed the autoscaling_fix_with_RunningReplicaInfo branch 2 times, most recently from d54a3c1 to 78a872c Compare February 23, 2023 21:01
size = "small",
srcs = serve_tests_srcs,
tags = ["exclusive", "team:serve"],
deps = [":serve_lib"],
Copy link
Contributor

Choose a reason for hiding this comment

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

This test file wasn't running in CI before? 😮

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly...

Copy link
Contributor

@architkulkarni architkulkarni left a comment

Choose a reason for hiding this comment

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

Nice catch! Is it feasible to add a test which fails without this change?

]
)
)
object.__setattr__(self, "_hash", hash_val)
Copy link
Contributor

Choose a reason for hiding this comment

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

For my education what's the benefit of this over self._hash = hash_val? If not obvious maybe add a code comment

Copy link
Contributor Author

@sihanwang41 sihanwang41 Feb 23, 2023

Choose a reason for hiding this comment

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

oh it is a hacky way to set attribute, since we use frozen for this dataclass class. (Not allow to set attribute as you mentioned)

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense! Would be good to put this in a code comment

python/ray/serve/tests/test_common.py Outdated Show resolved Hide resolved
python/ray/serve/_private/common.py Outdated Show resolved Hide resolved
@sihanwang41 sihanwang41 force-pushed the autoscaling_fix_with_RunningReplicaInfo branch from 78a872c to d9902cf Compare February 23, 2023 22:57
Signed-off-by: Sihan Wang <[email protected]>
Copy link
Contributor

@zcin zcin left a comment

Choose a reason for hiding this comment

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

Nice work! Learned some new things 😀

python/ray/serve/_private/common.py Outdated Show resolved Hide resolved
Co-authored-by: Cindy Zhang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
@architkulkarni
Copy link
Contributor

Linkcheck failure unrelated

@architkulkarni architkulkarni added the tests-ok The tagger certifies test failures are unrelated and assumes personal liability. label Feb 24, 2023
@architkulkarni architkulkarni merged commit c23c0db into ray-project:master Feb 24, 2023
sihanwang41 added a commit to sihanwang41/ray that referenced this pull request Mar 7, 2023
When the longpoll client timeout happens, the all internal objects will be cleaned up. The longpoll client will try to poll again. When this happens, longpoll client will receive another object which having same information but different object id (ActorHandle) from the controller.
Then after compute_iterable_delta is called, it will replace the same replica in in_flight_queries, and cause router clean up ongoing request_ref, and keep assigning new request to the replica, which will break the max_concurrent_queries parameter.

Related issue number
Closes ray-project#32652

Signed-off-by: Sihan Wang <[email protected]>
sihanwang41 added a commit that referenced this pull request Mar 7, 2023
* [Serve] Add hash function of RunningReplicaInfo (#32772)

When the longpoll client timeout happens, the all internal objects will be cleaned up. The longpoll client will try to poll again. When this happens, longpoll client will receive another object which having same information but different object id (ActorHandle) from the controller.
Then after compute_iterable_delta is called, it will replace the same replica in in_flight_queries, and cause router clean up ongoing request_ref, and keep assigning new request to the replica, which will break the max_concurrent_queries parameter.

Related issue number
Closes #32652

Signed-off-by: Sihan Wang <[email protected]>

* [Serve] Fix the max_concurrent_queries issue (#33022)

For the `hashable` object, __eq__ and __hash__ both need to be provided for correctness.  https://docs.python.org/3.9/glossary.html#term-hashable

And add tests to make sure the long poll timeout issue won't happen.

---------

Signed-off-by: Sihan Wang <[email protected]>
edoakes pushed a commit to edoakes/ray that referenced this pull request Mar 22, 2023
When the longpoll client timeout happens, the all internal objects will be cleaned up. The longpoll client will try to poll again. When this happens, longpoll client will receive another object which having same information but different object id (ActorHandle) from the controller.
Then after compute_iterable_delta is called, it will replace the same replica in in_flight_queries, and cause router clean up ongoing request_ref, and keep assigning new request to the replica, which will break the max_concurrent_queries parameter.

Related issue number
Closes ray-project#32652

Signed-off-by: Edward Oakes <[email protected]>
peytondmurray pushed a commit to peytondmurray/ray that referenced this pull request Mar 22, 2023
When the longpoll client timeout happens, the all internal objects will be cleaned up. The longpoll client will try to poll again. When this happens, longpoll client will receive another object which having same information but different object id (ActorHandle) from the controller.
Then after compute_iterable_delta is called, it will replace the same replica in in_flight_queries, and cause router clean up ongoing request_ref, and keep assigning new request to the replica, which will break the max_concurrent_queries parameter.

Related issue number
Closes ray-project#32652
elliottower pushed a commit to elliottower/ray that referenced this pull request Apr 22, 2023
When the longpoll client timeout happens, the all internal objects will be cleaned up. The longpoll client will try to poll again. When this happens, longpoll client will receive another object which having same information but different object id (ActorHandle) from the controller.
Then after compute_iterable_delta is called, it will replace the same replica in in_flight_queries, and cause router clean up ongoing request_ref, and keep assigning new request to the replica, which will break the max_concurrent_queries parameter.

Related issue number
Closes ray-project#32652

Signed-off-by: elliottower <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests-ok The tagger certifies test failures are unrelated and assumes personal liability.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Serve] max_concurrent_queries=1 is ignored when autoscaling
5 participants