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

[Cherry-pick][Streaming Generator] Fix a reference leak when a stream is deleted w… #35707

Conversation

rkooo567
Copy link
Contributor

@rkooo567 rkooo567 commented May 24, 2023

…ith out of order writes. (#35591)

Currently, when we delete the ObjectRefStream, we have the following logics.

Keeps reading the next references
If it reaches EoF, finish reading it.
If there's no next index, finish reading it.
Since all these unconsumed objects have a local reference we call RemoveLocalReferences to remove references. This doesn't work well when the items are written in out of order, For example, see the following example.

Write (index 1) -> Delete -> Write (index 0). In this case, Delete thinks there's no references in the stream because it checks index 0 and found there's no references. It stops reading the stream. This works when the ordering of write is ensured, but not when it is not.

This PR fixes the issue by instead reading all unconsumed references via GetItemsUnconsumed API. This API will return every references that are not read yet.

When the references are written out of order,

Why are these changes needed?

Related issue number

#35634

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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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 :(

…ith out of order writes. (ray-project#35591)

Currently, when we delete the ObjectRefStream, we have the following logics.

Keeps reading the next references
If it reaches EoF, finish reading it.
If there's no next index, finish reading it.
Since all these unconsumed objects have a local reference we call RemoveLocalReferences to remove references.
This doesn't work well when the items are written in out of order, For example, see the following example.

Write (index 1) -> Delete -> Write (index 0). In this case, Delete thinks there's no references in the stream because it checks index 0 and found there's no references. It stops reading the stream. This works when the ordering of write is ensured, but not when it is not.

This PR fixes the issue by instead reading all unconsumed references via GetItemsUnconsumed API. This API will return every references that are not read yet.

When the references are written out of order,
Copy link
Collaborator

@zhe-thoughts zhe-thoughts left a comment

Choose a reason for hiding this comment

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

Let's pick and be careful of issues. cc @ArturNiederfahrenhorst and @can-anyscale

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