You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Ilya Korol (Jira)" <ji...@apache.org> on 2022/07/13 06:50:00 UTC

[jira] [Created] (IGNITE-17362) GridLuceneFile filename remains in the GridLuceneDirectory.fileMap after IndexOutput was closed

Ilya Korol created IGNITE-17362:
-----------------------------------

             Summary: GridLuceneFile filename remains in the GridLuceneDirectory.fileMap after IndexOutput was closed
                 Key: IGNITE-17362
                 URL: https://issues.apache.org/jira/browse/IGNITE-17362
             Project: Ignite
          Issue Type: Bug
    Affects Versions: 2.13
            Reporter: Ilya Korol


I'm not sure whether this is a bug or not, need someone who has good understanding of lucene related machinery.


{code:java}
package org.apache.ignite.internal.processors.query.h2.opt;

// imports

public class GridLuceneDirectoryTest extends GridCommonAbstractTest {

    private GridLuceneDirectory dir;

    @Before
    public void setUp() throws Exception {
        dir = new GridLuceneDirectory(new GridUnsafeMemory(0));
    }

    @Test
    public void testReleaseRefShouldRemoveFileNameFromDirMap() throws IOException {
        final String fileName = "foo";

        assertNoFilenames();
        IndexOutput indexOutput = dir.createOutput(fileName, IOContext.DEFAULT);
        assertTrue("Missing created file: " + fileName, dirFileNames().contains(fileName));

        indexOutput.close();

        // Now underlying file ref count is 0 that triggers GridLuceneFile.deferredDelete()
        // however dir would still hold a reference to this file in GridLuceneDirectory.fileMap
        assertNoFilenames();
        assertNoPendingDeletions();
    }

    private List<String> dirFileNames() {
        return Arrays.asList(dir.listAll());
    }

    private void assertNoFilenames() {
        assertTrue("Lucene Directory is not empty", dirFileNames().isEmpty());
    }

    private void assertNoPendingDeletions() throws IOException {
        assertTrue("Pending deletions is not empty", dir.getPendingDeletions().isEmpty());
    }
}
{code}




--
This message was sent by Atlassian Jira
(v8.20.10#820010)