ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Ozerov <voze...@gridgain.com>
Subject Re: Semaphore blocking on tryAcquire() while holding a cache-lock
Date Wed, 17 Feb 2016 07:13:00 GMT
Cross-posting to the dev-list.

Hi Mario,
Thank you for source code. I was able to reproduce the issue and deduced it
to simpler example when two nodes start in a single JVM and one of the
holds key lock. See https://issues.apache.org/jira/browse/IGNITE-2671

Igniters,
I think someone with experience with cache/preload should throw a glance at
this ticket. Looks pretty nasty to me. Essentially, new node cannot join
topology when a single cache key lock is held.

Vladimir.

On Tue, Feb 16, 2016 at 8:33 PM, nyname00 <mario.stark@panagenda.com> wrote:

> Yakov,
>
> please see the code below. Simply start one node (in my case I started it
> directly from eclipse using 1.8u45) and wait for a few cycles, then start
> up
> the second node. You should see one more "sem created" message and then ...
> silence. If you kill the first node, the code processes normal again - but
> not when you kill the second one.
>
> Also note that on the second node no "Topology snapshot" message appears
> which, I guess, is not a good sign.
>
> I'm still testing, but if you replace the "sched" map-lock with a
> semaphore,
> everything seems to work ... until you kill one of the nodes. Then an
> exception is thrown every time the worker tries to get a new semaphore.
>
> Thanks for investigating,
> Mario
>
>
> public static void main(String[] args) {
>         Ignite ignite = Ignition.start(new IgniteConfiguration());
>
>         Lock lock = ignite
>                 .getOrCreateCache(
>                         new CacheConfiguration<String,
> Boolean>("sched").setAtomicityMode(TRANSACTIONAL))
>                 .lock("sched-lock");
>
>         if (lock.tryLock()) {
>             try {
>                 System.out.println("pre start sched");
>
>                 ScheduledExecutorService es =
> Executors.newSingleThreadScheduledExecutor();
>                 ScheduledFuture<?> f = es.scheduleAtFixedRate(new
> Worker(ignite), 0, 2000,
> TimeUnit.MILLISECONDS);
>
>                 System.out.println("post start sched");
>                 try {
>                     f.get();
>                 } catch (Exception e) {
>                     e.printStackTrace();
>                 } finally {
>                     es.shutdownNow();
>                 }
>             } finally {
>                 lock.unlock();
>             }
>         }
>     }
>
>     private static class Worker implements Runnable {
>         private final Ignite ignite;
>
>         public Worker(Ignite ignite) {
>             this.ignite = ignite;
>         }
>
>         @Override
>         public void run() {
>             IgniteSemaphore sem = ignite.semaphore("sem-worker-1", 1,
> true, true);
>
>             System.out.println("sem created");
>             if (sem.tryAcquire()) {
>                 try {
>                     System.out.println("sem aquired");
>                 } finally {
>                     sem.release();
>                     System.out.println("sem released");
>                 }
>             } else {
>                 System.out.println("sem not aquired");
>             }
>         }
>     }
>
>
> yakov wrote
> > Hi Mario!
> >
> > Can you please share the code somehow? Reproducible example will be very
> > helpful.
> >
> > --Yakov
> >
> > 2016-02-16 16:57 GMT+03:00 nyname00 &lt;
>
> > mario.stark@
>
> > &gt;:
> >
> >> Hi Igniters,
> >>
> >> I'm getting some strange behavior when I try to call
> >> IgniteSemaphore#tryAquire() while holding a lock on a cache element -
> the
> >> method seems block forever.
> >>
> >> Here's the details:
> >>   - create a cache (default, transactional) and get a lock using
> >> Lock#tryLock()
> >>   - start a Executors.newSingleThreadScheduledExecutor() and schedule a
> >> worker to run every n seconds
> >>   - in the worker, get a semaphore and call IgniteSemaphore#tryAcquire()
> >>   - do some work and call IgniteSemaphore#release()
> >> (except for the cache/lock and semaphore no Ignite API calls are made)
> >>
> >> The whole thing works for a single node, but as soon as I start up an
> new
> >> node (with the same code) the IgniteSemaphore#tryAcquire() call starts
> >> blocking.
> >>
> >> Is this this a known limitation/issue or am I doing something wrong
> here?
> >>
> >> Thanks in advance,
> >> Mario
> >>
> >> ps: when I replace the cache-lock with an other semaphore, it works
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://apache-ignite-users.70518.x6.nabble.com/Semaphore-blocking-on-tryAcquire-while-holding-a-cache-lock-tp3031.html
> >> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
> >>
>
>
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Semaphore-blocking-on-tryAcquire-while-holding-a-cache-lock-tp3031p3034.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message