Vyacheslav Koptilin created IGNITE-14624:
--------------------------------------------

             Summary: WalSegmentSyncer stops in an incorrect way
                 Key: IGNITE-14624
                 URL: https://issues.apache.org/jira/browse/IGNITE-14624
             Project: Ignite
          Issue Type: Bug
            Reporter: Vyacheslav Koptilin
            Assignee: Vyacheslav Koptilin


{{WalSegmentSyncer#shutdown}} uses {{U.join(GridWorker, IgniteLogger)}} method 
which delegates to {{GridWorker#join()}}

{code:java|title=GridWorker.java}
    public void join() throws InterruptedException {
        ...
        if ((runner == null && isCancelled) || finished)
            return;

        synchronized (mux) {
            while (!finished)
                mux.wait();
        }
    }
{code}

On the other hand, {{GridWorker#run()}} nullifies the {{runner}} field *after* 
the worker notifies all threads that work is finished:

{code:java|title=GridWorker.java}
    @Override public final void run() {
        // Runner thread must be recorded first as other operations
        // may depend on it being present.
        runner = Thread.currentThread();
        try {
            ...
            body();
        }
        catch (Throwable e) {
            ...
        }
        finally {
            synchronized (mux) {
                finished = true;
                mux.notifyAll();
            }
            ...
            // Need to set runner to null, to make sure that
            // further operations on this runnable won't
            // affect the thread which could have been recycled
            // by thread pool.
            runner = null;
        }
    }
{code}

This can lead to {{AssertionError}} like the following:
{noformat}
java.lang.AssertionError: WalSegmentSyncer is running.
        
org.apache.ignite.internal.processors.cache.persistence.wal.filehandle.FileHandleManagerImpl$WalSegmentSyncer.restart(FileHandleManagerImpl.java:646)
        
org.apache.ignite.internal.processors.cache.persistence.wal.filehandle.FileHandleManagerImpl.resumeLogging(FileHandleManagerImpl.java:235)
        
org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager.resumeLogging(FileWriteAheadLogManager.java:705)
        
org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.resumeWalLogging(GridCacheDatabaseSharedManager.java:1707)
        
org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.finishRecovery(GridCacheDatabaseSharedManager.java:757)
        
org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.onActivate(GridCacheDatabaseSharedManager.java:637)
        
org.apache.ignite.internal.processors.cache.GridCacheSharedContext.activate(GridCacheSharedContext.java:296)
        
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.onClusterStateChangeRequest(GridDhtPartitionsExchangeFuture.java:1322)
        
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.init(GridDhtPartitionsExchangeFuture.java:964)
        
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:3375)
        
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:3194)
        
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:119)
        java.lang.Thread.run(Thread.java:748)
{noformat}




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to