-
-
Notifications
You must be signed in to change notification settings - Fork 627
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[bug][regression] mysql2.setMaxParserCache fails with TypeError #2752
Comments
Can you try to find a way to change the size in lru-cache? You a probably right, looks like this was an option in earlier versions of lru-cache but no longer is Alternatively we can refactor |
According to its readme, they initialize internal structures based on max size and it's too complicated to adjust them to the new size, so it cannot be changed now…
There already is per-connection cache for prepared statements. I doubt there needs to be another one. Also it would reduce cache hit-rate in cases where same queries can be used across multiple connections or even connection pools. Actually global parser cache makes total sense. As an alternative an option to bypass the cache on specific queries could be implemented, but that maybe a bit too complicated too… Setting size by recreating cache seems like a simple solution. Instead of |
made a PR to speed up resolution of this one :) |
* fix #2752 setMaxParserCache throws TypeError
I believe it's worth keeping this issue open (or open a new one if it's more convenient). For context: node-mysql2/lib/parsers/parser_cache.js Lines 5 to 7 in 1abc799
node-mysql2/lib/parsers/parser_cache.js Lines 53 to 55 in 1abc799
Although it's a very specific case, an example of when we lost 15,000 caches without benefit after for (let i = 0; i < 15_000; i++) {
await conn.execute(`SELECT ${i}+${i} as total${i}`);
}
// Allowing 50,000 caches
mysql.setMaxParserCache(50_000);
The same problem reducing cache size: for (let i = 0; i < 15_000; i++) {
await conn.execute(`SELECT ${i}+${i} as total${i}`);
}
// Allowing 10,000 caches
mysql.setMaxParserCache(10_000);
When Also, it's not our case, but if we use Note I opened a PR (#2988) proposing a library change, where we could basically do this internally: parserCache.resize(max); |
Hi!
If I call
setMaxParserCache
imported from mysql2, I get an error:I really need to downsize this cache because it always ends up being full and consuming about 300Mb RAM. Probably something about my use case that makes it grow so big…
I believe somewhere along the way
lru-cache
changed its internals and cannot be resized anymore. I'd like ifsetMaxParserCache
would throw away an old cache and create a new one with right size in its place…The text was updated successfully, but these errors were encountered: