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

[Streaming Generator] Fix a reference leak when a stream is deleted with out of order writes. #35591

Merged
merged 1 commit into from
May 24, 2023

Conversation

rkooo567
Copy link
Contributor

@rkooo567 rkooo567 commented May 22, 2023

Why are these changes needed?

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,

Related issue number

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 :(

Signed-off-by: SangBin Cho <rkooo567@gmail.com>
@rkooo567 rkooo567 assigned jjyao and scv119 and unassigned jjyao May 22, 2023
@rkooo567 rkooo567 merged commit 10f2d7d into ray-project:master May 24, 2023
rkooo567 added a commit to rkooo567/ray that referenced this pull request May 24, 2023
…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,
rkooo567 added a commit that referenced this pull request May 24, 2023
…ith out of order writes. (#35591) (#35707)

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,
scv119 pushed a commit to scv119/ray that referenced this pull request Jun 16, 2023
…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,
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
…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,

Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
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.

3 participants