-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Searchable Snapshot] IndexInput clones close handling #5243
Comments
this has been estimated as 5 points |
Since the cloned instances are never explicitly closed, then java.lang.ref.Cleaner is the supported mechanism in Java for tracking when those references are no longer in use. However, given the stated behavior from Lucene:
Then the question is whether we need to track the cloned instances at all? Per the API contract the cloned instances should become unusable when the original instance is closed, so for the purpose of reference counting and ensuring the underlying cached objects remain alive then it seems possible that we can only track the original instance and ignore the clones (because Lucene ensures that cloned instances are never used beyond the lifetime of the original). We might need to add logic to the clones to fail with the appropriate AlreadyClosedException if they are accessed after the original is closed. |
The answer to this question is "yes". With the caching design, and IndexInput instance may end up fetching any number blocks from the cache. Beyond that, the cloned IndexInput instances may fetch different blocks from the cache than the original IndexInput. An alternative approach that doesn't require using the Cleaner could be to have the original IndexInput hold a reference to every block that it or its cloned IndexInputs touched throughout the lifetime of the original, and then release them all when the original is closed. Since we don't control how long that original IndexInput will stay alive, it is better to free the resources using the Cleaner when the clones become unreachable (which may happen while the original IndexInput is still being used, therefore releasing resources sooner than the alternative approach would). |
As detailed [in this issue][1], Lucene does not close the cloned IndexInput instances, so we are using the Cleaner mechanism from the JDK to close any unclosed clones. A single static Cleaner instance to ensure any unclosed clone of an IndexInput is closed. This instance creates a single daemon thread on which it performs the cleaning actions. For an already-closed IndexInput, the cleaning action is a no-op. For an open IndexInput, the close action will decrement a reference count. [1]: opensearch-project#5243 (comment) Signed-off-by: Andrew Ross <[email protected]>
As detailed [in this issue][1], Lucene does not close the cloned IndexInput instances, so we are using the Cleaner mechanism from the JDK to close any unclosed clones. A single static Cleaner instance to ensure any unclosed clone of an IndexInput is closed. This instance creates a single daemon thread on which it performs the cleaning actions. For an already-closed IndexInput, the cleaning action is a no-op. For an open IndexInput, the close action will decrement a reference count. [1]: opensearch-project#5243 (comment) Signed-off-by: Andrew Ross <[email protected]>
As detailed [in this issue][1], Lucene does not close the cloned IndexInput instances, so we are using the Cleaner mechanism from the JDK to close any unclosed clones. A single static Cleaner instance to ensure any unclosed clone of an IndexInput is closed. This instance creates a single daemon thread on which it performs the cleaning actions. For an already-closed IndexInput, the cleaning action is a no-op. For an open IndexInput, the close action will decrement a reference count. [1]: opensearch-project#5243 (comment) Signed-off-by: Andrew Ross <[email protected]>
As detailed [in this issue][1], Lucene does not close the cloned IndexInput instances, so we are using the Cleaner mechanism from the JDK to close any unclosed clones. A single static Cleaner instance to ensure any unclosed clone of an IndexInput is closed. This instance creates a single daemon thread on which it performs the cleaning actions. For an already-closed IndexInput, the cleaning action is a no-op. For an open IndexInput, the close action will decrement a reference count. [1]: opensearch-project#5243 (comment) Signed-off-by: Andrew Ross <[email protected]>
As detailed [in this issue][1], Lucene does not close the cloned IndexInput instances, so we are using the Cleaner mechanism from the JDK to close any unclosed clones. A single static Cleaner instance to ensure any unclosed clone of an IndexInput is closed. This instance creates a single daemon thread on which it performs the cleaning actions. For an already-closed IndexInput, the cleaning action is a no-op. For an open IndexInput, the close action will decrement a reference count. [1]: opensearch-project#5243 (comment) Signed-off-by: Andrew Ross <[email protected]>
As detailed [in this issue][1], Lucene does not close the cloned IndexInput instances, so we are using the Cleaner mechanism from the JDK to close any unclosed clones. A single static Cleaner instance to ensure any unclosed clone of an IndexInput is closed. This instance creates a single daemon thread on which it performs the cleaning actions. For an already-closed IndexInput, the cleaning action is a no-op. For an open IndexInput, the close action will decrement a reference count. [1]: #5243 (comment) Signed-off-by: Andrew Ross <[email protected]>
As detailed [in this issue][1], Lucene does not close the cloned IndexInput instances, so we are using the Cleaner mechanism from the JDK to close any unclosed clones. A single static Cleaner instance to ensure any unclosed clone of an IndexInput is closed. This instance creates a single daemon thread on which it performs the cleaning actions. For an already-closed IndexInput, the cleaning action is a no-op. For an open IndexInput, the close action will decrement a reference count. [1]: #5243 (comment) Signed-off-by: Andrew Ross <[email protected]> (cherry picked from commit dae1566) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
As detailed [in this issue][1], Lucene does not close the cloned IndexInput instances, so we are using the Cleaner mechanism from the JDK to close any unclosed clones. A single static Cleaner instance to ensure any unclosed clone of an IndexInput is closed. This instance creates a single daemon thread on which it performs the cleaning actions. For an already-closed IndexInput, the cleaning action is a no-op. For an open IndexInput, the close action will decrement a reference count. [1]: #5243 (comment) (cherry picked from commit dae1566) Signed-off-by: Andrew Ross <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
When Lucene clones IndexInput it will not close it, it will only close the original IndexInput. So we need to keep track of the cloned IndexInputs and close them when they are not used anymore. Scope here is find how to detect the unused IndexInput, is relying on GC and Cleaner is the only option here ? and then implement it
The text was updated successfully, but these errors were encountered: