Closed kewp closed 6 days ago
Is there anything else you are doing in your JS application code that is opening files?
I have this complex caching mechanism that uses KV. Maybe it's going awol? I will check
Are you spawning a bunch of workers? Or are you calling Deno.openKv
a lot?
To be honest I can't remember... let me get back to you
No spawning that I can see... just a lot of kv requests. Maybe I'm not closing them? I have a bunch of crons as well that use kv a lot
So particularly I am asking if you are doing a lot of this:
async function foo() {
const kv = await Deno.openKv();
await kv.set(); // or get, or atomic().commit(), or delete, etc
}
or if you are doing:
const kv = await Deno.openKv();
async function foo() {
await kv.set(); // or get, or atomic().commit(), or delete, etc
}
Are the crons registered at the global scope of the application?
I think they're global? I have a main server and a bunch of crons which are declared immediately at the top of the server code. I think I open kv once for each cron and use that. I'm driving I'll confirm in a few hours
is this bad @lucacasonato ?
Yes - you should close your kv instances after use (kv.close()
). Or just open a single one globally.
Aren't crons run in a separate process? I mean like on Deno Deploy? So can I use a global kv instance there?
I've closed it at the end ... going to monitor how many open files it has ...
Yup I think that was it. Open files holding at around 100
You can open it at the top - they can close over JS values like any other function.
Hmm that's too high level javascript for me but thanks, I'll read up on that ...
Should I close the issue?
@lucacasonato I'm getting errors now on deno deploy ...
I'm guessing it's because ... when you close kv ... it closes it in other places too?
I just got the following panic in my server:
I did an
lsof
on the running process and I'm seeing a ton of these entries:I'm guessing this is ...
kv
?