Deno Kv: "Database is locked" on enqueue
I'm running 2 Deno services. Service
1
gathers info and posts it to service 2
via HTTP post, where 2
immediately offloads the request to a Deno.kv
queue and returns. There are a lot of posts being made, and once a couple thousand events are queued I'm noticing that inconsistently service 2
will throw the following error:
the controller handling these calls looks like the following:
It doesn't seem to be breaking consistently after 'x amount of queued items' or anything like that, from what I can see.
I'm not quite sure what is causing it, perhaps anyone else has some experience with this? Thanks for any help2 Replies
Apparently this happens when multiple processes try access the
kv
db file at the same time. I'm not sure how to prevent it as of yet. For now I've gotten around it by implementing a retry mechanism for the enqueue
call, it just attempts to enqueue in a try catch within a for loop a couple times. I haven't run into a case where it fails to enqueue more than once so this seems to be fine for what I need for now.I'd recommend opening a bug for this. Sounds like a bug in their local Kv implementation.