Comments (8)
@epelc, thank you for reporting this bug and I'm sorry that this is causing you problems. I wanted to let you know that I saw this and I'll be working on helping you as soon as I can. Unfortunately because of work I won't be able to spend any real time on this until Thursday or Friday.
from jobs.
@epelc I am unable to reproduce this. There is a test for Destroy
that passes on my machine. If you are able to reproduce the bug consistently, would you mind telling me exactly how? If possible it would help tremendously to see some code.
from jobs.
To answer your questions:
- I cannot answer that question until I better understand what you're doing and what is causing the bug. I can imagine a scenario where it can cause problems if you try and destroy a job while it's still being executed by some worker.
- Yes,
Destroy
is supposed to remove all traces of the job from the database. It sounds like some bug is preventingDestroy
from finishing and that's why you're still seeing some fields.
As an aside, it appears that the bug is occurring in the middle of a transaction. Redis is not ACID, so it is possible for a transaction to partially execute, leaving the database in an inconsistent state. If I understand correctly, the redis-check-aof tool will help remedy this and put the database back into a consistent state.
from jobs.
@albrow Just got back from lunch. I'll explain what I'm doing a bit more before I try to get it reproduced.
- I register a job
- The job runs several times
- During the job if it reaches a certain state destroys itself
Heres some psuedo code for the job function
func updateTrackingJob(shipmentId bson.ObjectId) error {
// Lookup the shipment info in mongodb so we can get the job id
// When we register the job we save it's id to our shipment
s := findShipment(shipmentId)
// do some work
// if the work returns a certain case we need to destroy the job and remove it from our shipment
j,err := jobs.FindById(s.JobId)
if err != nil {
return err
}
err = j.Destroy()
if err != nil {
return err
}
//remove the job id from our shipment
return nil
}
from jobs.
@albrow I haven't been able to reliable reproduce it 100% but I think I found the cause.
The workers doJob
function doesn't handle jobs which destroy them self during execution.
https://github.com/albrow/jobs/blob/master/worker.go#L92
Note it always sets the time
and finished
fields. It also adds it back to the jobs:time
set which I think is causing it to run again without any info in the status
field which is causing the erorr in the destroy script.
hget
returns nil when the field doesn't exist which I think is evaluating as falsey in lua.
Return value
Bulk string reply: the value associated with field, or nil when field is not present in the hash or key does not exist.
If you run this you can see that it does set the time
and finished
fields along with putting it in jobs:time
after you destroy the job in the handler.
https://gist.github.com/epelc/3512e1e40e6cfc3cefc3
Note use the -vjl
flag to see it find the id and destroy the jobs. Also it using db number 4 so SELECT 4
to get to it.
Let me know your thoughts are.
from jobs.
@epelc okay I see what's happening now. I didn't anticipate anyone destroying a job in a job hander while it was being executed. I have a fix in mind and will be creating a PR soon. When the PR is up, I would appreciate it if you could take a look and make sure it solves your problem.
from jobs.
I'll definitely test it out. Just let me know when it's ready.
On Jul 4, 2015 4:50 PM, "Alex Browne" [email protected] wrote:
@epelc https://github.com/epelc okay I see what's happening now. I
didn't anticipate anyone destroying a job in a job hander while it was
being executed. I have a fix in mind, and will be creating a PR soon. When
the PR is up, I would appreciate it if you could take a look and make sure
it solves your problem.—
Reply to this email directly or view it on GitHub
#26 (comment).
from jobs.
@epelc please check out #27. On that branch, I can run https://gist.github.com/epelc/3512e1e40e6cfc3cefc3 and get the expected results. That is, there are no remnants of the jobs if they are destroyed from inside a handler, and there are no errors or panics.
from jobs.
Related Issues (20)
- Use go generate to convert lua script files to strings HOT 4
- Use an interface for jobs instead of a non-type-safe handler function (would break backwards-compatibility) HOT 4
- Support redis sentinel HOT 6
- Export job.freq HOT 4
- Reschedule with freq HOT 2
- FindById() doesn't return error for missing jobs HOT 7
- Add a changelog HOT 2
- Panic in xen container HOT 4
- Job runtime error messages should include a stack trace
- job not exec with panic HOT 8
- FindById and job identifiers/human names HOT 6
- Examples?
- Passing params / string name of job. HOT 2
- Endless loop? HOT 6
- Error Handling? HOT 5
- Application can't start due to error which message is 'jobs: In scanJob: Could not find Type with name = %s' HOT 1
- super slow HOT 1
- Support environmental prefix
- Job status is changed to executing but job has not started execution
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 jobs.