Comments (7)
I can't reproduce the issue. I also verified that a new session is created for each lock handler regardless of whether it shares the same JVM process with other handlers. Session creation is performed once per Bootique runtime (io.bootique.job.consul.ConsulSession#getOrCreateSession
) and boils down to REST session/create
call to Consul agent, which fills the node ID parameter in the request and forwards the call to the server [1]. Upon receiving session creation requests Consul server always creates a new session with a random ID [2]. This unique ID is then used by our lock handler to lock a key-value node in Consul (also implemented as a REST call, which ends up in Consul's transactional key-value store [3]).
I can't see any reason for the behavior that you observe other than the two jobs being run with a signficant time gap:
scheduler_1.runOnce(new LockJob(), callsCount);
scheduler_2.runOnce(new LockJob(), callsCount);
But this is super-strange, given that a thread-pool executor with multiple worker threads is used in your test. Are you sure that you can reproduce the issue?
from bootique-job.
Test failure (from PR #70) is reproducible on my machine too (MacOS).
@atomashpolskiy can you please review test itself, is it correct?
Here is log:
[main] INFO 🐳 [consul:latest] - Container consul:latest started
[main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Initializing ExecutorService
[bootique-job-1] INFO io.bootique.job.consul.lock.ConsulLockHandler - Attempting to lock 'TestJobs/lock'
[bootique-job-2] INFO io.bootique.job.consul.lock.ConsulLockHandler - Attempting to lock 'TestJobs/lock'
[bootique-job-2] ERROR io.bootique.job.consul.lock.ConsulLockHandler - Failed to release lock, manual intervention might be needed: TestJobs/lock
[pool-2-thread-1] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Shutting down ExecutorService
java.lang.AssertionError:
Expected :1
Actual :2
from bootique-job.
from bootique-job.
Cool, thanks! Different OS can be the case here (at least Docker can perform differently).
AFAIK Maxim run tests on Mac too.
from bootique-job.
Turns out, I was looking at and talking about testConsulClusterJobLocking
. Sorry :)
Regarding the testConsulLocalJobLocking
test: from my point of view this behavior (lock reentrancy, basically) is to be expected. And in any case, why would you ever need two job instances running simultaneously in the same Bootique runtime?
from bootique-job.
I guess that the fool-proof solution would be to always decorate serial jobs with an additional local lock :)
from bootique-job.
Suppose, we have api for running job, without local locking we can start several executions of a one job (with one bqruntime).
P.S. bootique-zookeeper has clustered and local locking mechanism.
from bootique-job.
Related Issues (20)
- Job listeners are not notified when a job throws an exception
- Jobs with dependencies and job groups cause deadlocks on pool starvation HOT 3
- Job group to reuse the group dispatch thread when possible
- @SerialJob should be part of the Job metadata
- Reorg JobFuture hierarchy HOT 1
- Refactoring to classic module layout
- Upgrade Consul client to 1.5.3
- Unify job decoration approach
- Package reorg
- Add job dependencies to the JobMetadata
- Unify configuration of jobs and groups
- Distinguish between repeating and unique jobs in job graphs
- ExecCommand status reporting: "message: null"
- NPE during registry startup when a job with dependencies delcares params
- Refactor JobModule into two module classes within the same jar
- bootique-job: remove optional dependency on curator ZK client
- TriggerFactory should create a mutable parameters map
- Failure in JobListener must fail the job
- Enhanced API for job parameters
- Support passing parameters to jobs via CLI
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 bootique-job.