Comments (2)
This should be possible by 1) ensuring that all the jobs in that queue are completed or canceled and then 2) calling queue.forget
on the queue to remove it from the list of known queues. This will avoid all leakage.
from qless-core.
For our case, the deletion of queue is triggered by the user from our UI. We need cancel all jobs in the queue asap. So we write a small lua script:
In queue.lua, add this function:
{code}
-- List jobs and their depends ids
function QlessQueue.jobs(now, name, count)
local queue = Qless.queue(name)
-- These are the ids that we're going to return. We'll begin with any jobs
-- that have lost their locks
local jids = queue.work.peek(count)
table.extend(jids, queue.locks.peek(now, 0, count - #jids))
table.extend(jids, queue.scheduled.peek(now, 0, count - #jids))
table.extend(jids, queue.recurring.peek(now, 0, count - #jids))
local dependents = {}
for _, jid in ipairs(jids) do
dependents[jid] = redis.call(
'smembers', QlessJob.ns .. jid .. '-dependents') or {}
end
table.extend(jids, dependents)
return jids
end
{code}
In api.lua, we write this
{code}
QlessAPI['job.batch_cancel'] = function(now, queue, count)
local jids = QlessQueue.jobs(now, queue, count)
Qless.cancel(unpack(jids))
return #jids
end
{code}
In this way, our application can repeat calling job.batch_cancel to cancel all jobs in the queue. Then we can safely delete the queue.
Let's know if this is OK or not.
Thanks a lot!
Yan
from qless-core.
Related Issues (20)
- tag.get takes start/end offsets but claims to take offset/count
- Consider truncating history as it grows HOT 2
- Support throttling on arbitrary resource names HOT 6
- Resolving dependencies on job failures HOT 2
- Idea: publish a message to workers when a queue moves from empty to non-empty HOT 6
- Documentation regarding priority is incorrect
- max_retries seems a bit restrictive, design-wise
- ql:tracked set is leaking canceled jobs
- Clarification on how scheduled dates are calculated HOT 3
- Tagged recurring jobs aren't returned by tag get/top commands HOT 2
- Allow `top tags` API to return all tags HOT 6
- Lua Script Error on Redis 3.2 HOT 1
- Unable to use the library HOT 1
- Encode math.huge HOT 3
- Use vararg expression instead `arg` table.
- Cleanup failed jobs. HOT 3
- Jobs that exhaust retries don't publish to `failed` channel
- Project stewardship? HOT 2
- Fails on redis 6.2.7 and redis 7.0 due to globally reachable lua tables becoming read only
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qless-core.