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

Query Results get cached even if noCaching is true #467

Open
seanhurwitz opened this issue Nov 19, 2024 · 11 comments
Open

Query Results get cached even if noCaching is true #467

seanhurwitz opened this issue Nov 19, 2024 · 11 comments
Assignees

Comments

@seanhurwitz
Copy link

image

I have set noCaching to true on each session, but this still gets cached. This is giving us a massive memory leak.
Please help!

@ml054
Copy link
Member

ml054 commented Nov 19, 2024

Hi @seanhurwitz

Which version of node.js client are you using?

@ml054 ml054 self-assigned this Nov 19, 2024
@seanhurwitz
Copy link
Author

@ml054 6.0.0

I believe the issue is (RequestExecutor.ts):

image

this._cache is always defined

and the method checks if(cache) cacheResponse(...)

so I suggest:
responseDispose = await command.processResponse(sessionInfo.noCaching ? undefined : this._cache, response, bodyStream, req.uri as string);

@seanhurwitz
Copy link
Author

I also set maxHttpCacheSize to 0 but that doesn't help. At least this will on a per session basis. But maybe if the size is 0, it shouldn't initialise the cache at all

@seanhurwitz
Copy link
Author

node version 20.16.0

@seanhurwitz
Copy link
Author

image
I set that cache variable to undefined in my node_modules and it doesn't cache anymore

@ml054
Copy link
Member

ml054 commented Nov 19, 2024

@seanhurwitz

  it("noCaching - on session", async () => {
        const session = store.openSession({
            noCaching: true
        });

        await session.query<BlogPost>({ collection: "blogPosts" })
            .all();

        console.log("noCaching - on session", store.getRequestExecutor().cache.numberOfItems);
        // it prints 1
    });

    it("noCaching - on query", async () => {
        const session = store.openSession();

        await session.query<BlogPost>({ collection: "blogPosts" })
            .noCaching()
            .all();

        console.log("noCaching - on query", store.getRequestExecutor().cache.numberOfItems);
        // it prints 0
    });

Please compare those two examples. First uses noCaching as session option, second noCache on query.

Can you confirm using noCaching on session.query doesn't cause memory leaks?

I will investiage futher why there is such disprancy and get back to you. I have hope that temporary workaround can unblock your development/deployments for time being.

@seanhurwitz
Copy link
Author

@ml054 I can confirm it works! Thanks. Please see to the issue though, it's tediuous to say noCaching every time

@ml054
Copy link
Member

ml054 commented Nov 20, 2024

I do agree. Will open a ticket for RavenDB to fix it. Sorry for inconvenience.

@ml054
Copy link
Member

ml054 commented Nov 21, 2024

@seanhurwitz
Copy link
Author

thanks. Just to clarify

Store level caching: (ie maxHttpCache = 0) DOESN'T WORK

Session level Caching (ie .openSession({noCaching:true}) DOESN'T WORK


Query level Caching (.noCaching()) DOES WORK

Seems the issue was only raised for Sesison Level Caching, can we not also fix it for Store level caching?

@ml054
Copy link
Member

ml054 commented Nov 21, 2024

Sure, reported separate ticket for node.js: https://issues.hibernatingrhinos.com/issue/RDBC-881/Node.js-client-cache-issues

Thanks

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

No branches or pull requests

2 participants