pg-boss icon indicating copy to clipboard operation
pg-boss copied to clipboard

Is there a way to force deleting the queue?

Open ckblockit opened this issue 9 months ago • 1 comments

I am using publish / subscribe to manage the workers across multiple instances. Every time we spin up a new instance, it will create a special queue that subscribes to any command event like "start" or "stop"

The problem arises when we'd like to clean up this special queue when we shut down this instance. I want to delete the queue, but it will fail if there's any "completed" job in the queue. I had to manually set the archiveAfterCompletd to 5 seconds, but that will limit us to use the cron.

  1. Is there a better way to manage workers across instances?
  2. If not, is there a way to force deleting the queue even if there's any job in the queue?

ckblockit avatar Mar 28 '25 21:03 ckblockit

You can use deleteQueue()

timgit avatar Apr 04 '25 00:04 timgit

I think @ckblockit is using the deleteQueue() function. But the function fails if there are still jobs in the job table corresponding to that queue.

When runnnig boss.deleteQueue('test') on a queue which still has jobs in the job table:

error: update or delete on table "queue" violates foreign key constraint "q_fkey" on table "j90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809"
Key (name)=(test) is still referenced from table "j90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809".'

It does not matter if all those jobs are already completed.

aa-ndrej avatar Jul 07 '25 13:07 aa-ndrej

This is already fixed in v11, but I haven't back ported it to v10 yet. Thanks for the nudge. I am almost ready to send it, but it's a big semver this time.

timgit avatar Jul 07 '25 15:07 timgit

Also running into this. Glad to see it's resolved in the new version. Any ETA for v11? Thanks for all your work on this library @timgit , use it across a number of projects and love it.

bam4564 avatar Aug 07 '25 17:08 bam4564

I should be able to get this out by the end of this month. The biggest delay right now is determining "what to do with stately queues"

timgit avatar Sep 05 '25 15:09 timgit