Coder Social home page Coder Social logo

Comments (7)

atomashpolskiy avatar atomashpolskiy commented on August 16, 2024

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.

stariy95 avatar stariy95 commented on August 16, 2024

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.

atomashpolskiy avatar atomashpolskiy commented on August 16, 2024

from bootique-job.

stariy95 avatar stariy95 commented on August 16, 2024

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.

atomashpolskiy avatar atomashpolskiy commented on August 16, 2024

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.

atomashpolskiy avatar atomashpolskiy commented on August 16, 2024

I guess that the fool-proof solution would be to always decorate serial jobs with an additional local lock :)

from bootique-job.

MegaPapa avatar MegaPapa commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.