Search in sources :

Example 1 with IgniteDiagnosticPrepareContext

use of org.apache.ignite.internal.IgniteDiagnosticPrepareContext in project ignite by apache.

the class GridCachePartitionExchangeManager method dumpLongRunningOperations0.

/**
 * @param timeout Operation timeout.
 * @return {@code True} if found long running operations.
 */
private boolean dumpLongRunningOperations0(long timeout) {
    long curTime = U.currentTimeMillis();
    boolean found = false;
    IgniteTxManager tm = cctx.tm();
    GridCacheMvccManager mvcc = cctx.mvcc();
    final IgniteDiagnosticPrepareContext diagCtx = cctx.kernalContext().cluster().diagnosticEnabled() ? new IgniteDiagnosticPrepareContext(cctx.localNodeId()) : null;
    if (tm != null) {
        WarningsGroup warnings = new WarningsGroup("First %d long running transactions [total=%d]", diagnosticLog, DIAGNOSTIC_WARN_LIMIT);
        synchronized (ltrDumpLimiter) {
            for (IgniteInternalTx tx : tm.activeTransactions()) {
                if (curTime - tx.startTime() > timeout) {
                    found = true;
                    if (warnings.canAddMessage()) {
                        warnings.add(longRunningTransactionWarning(tx, curTime));
                        if (cctx.tm().txOwnerDumpRequestsAllowed() && !Optional.ofNullable(cctx.kernalContext().config().isClientMode()).orElse(false) && tx.local() && tx.state() == TransactionState.ACTIVE && ltrDumpLimiter.allowAction(tx))
                            dumpLongRunningTransaction(tx);
                    } else
                        warnings.incTotal();
                }
            }
            ltrDumpLimiter.trim();
        }
        warnings.printToLog();
    }
    if (mvcc != null) {
        WarningsGroup activeWarnings = new WarningsGroup("First %d long running cache futures [total=%d]", diagnosticLog, DIAGNOSTIC_WARN_LIMIT);
        for (GridCacheFuture<?> fut : mvcc.activeFutures()) {
            if (curTime - fut.startTime() > timeout) {
                found = true;
                if (activeWarnings.canAddMessage()) {
                    activeWarnings.add(">>> Future [startTime=" + formatTime(fut.startTime()) + ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
                } else
                    activeWarnings.incTotal();
                if (diagCtx != null && fut instanceof IgniteDiagnosticAware)
                    ((IgniteDiagnosticAware) fut).addDiagnosticRequest(diagCtx);
            }
        }
        activeWarnings.printToLog();
        WarningsGroup atomicWarnings = new WarningsGroup("First %d long running cache futures [total=%d]", diagnosticLog, DIAGNOSTIC_WARN_LIMIT);
        for (GridCacheFuture<?> fut : mvcc.atomicFutures()) {
            if (curTime - fut.startTime() > timeout) {
                found = true;
                if (atomicWarnings.canAddMessage()) {
                    atomicWarnings.add(">>> Future [startTime=" + formatTime(fut.startTime()) + ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
                } else
                    atomicWarnings.incTotal();
                if (diagCtx != null && fut instanceof IgniteDiagnosticAware)
                    ((IgniteDiagnosticAware) fut).addDiagnosticRequest(diagCtx);
            }
        }
        atomicWarnings.printToLog();
    }
    if (diagCtx != null && !diagCtx.empty()) {
        try {
            cctx.kernalContext().closure().runLocal(new Runnable() {

                @Override
                public void run() {
                    diagCtx.send(cctx.kernalContext(), null);
                }
            }, SYSTEM_POOL);
        } catch (IgniteCheckedException e) {
            U.error(diagnosticLog, "Failed to submit diagnostic closure: " + e, e);
        }
    }
    return found;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteDiagnosticPrepareContext(org.apache.ignite.internal.IgniteDiagnosticPrepareContext) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) IgniteDiagnosticAware(org.apache.ignite.internal.IgniteDiagnosticAware) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)

Example 2 with IgniteDiagnosticPrepareContext

use of org.apache.ignite.internal.IgniteDiagnosticPrepareContext in project ignite by apache.

the class GridCachePartitionExchangeManager method dumpDebugInfo.

/**
 * @param exchFut Optional current exchange future.
 * @throws Exception If failed.
 */
public void dumpDebugInfo(@Nullable GridDhtPartitionsExchangeFuture exchFut) throws Exception {
    AffinityTopologyVersion exchTopVer = exchFut != null ? exchFut.initialVersion() : null;
    U.warn(diagnosticLog, "Ready affinity version: " + exchFuts.readyTopVer());
    U.warn(diagnosticLog, "Last exchange future: " + lastInitializedFut);
    exchWorker.dumpExchangeDebugInfo();
    if (!readyFuts.isEmpty()) {
        int warningsLimit = IgniteSystemProperties.getInteger(IGNITE_DIAGNOSTIC_WARN_LIMIT, 5);
        U.warn(diagnosticLog, "First " + warningsLimit + " pending affinity ready futures [total=" + readyFuts.size() + ']');
        if (warningsLimit > 0) {
            int cnt = 0;
            for (AffinityReadyFuture fut : readyFuts.values()) {
                U.warn(diagnosticLog, ">>> " + fut);
                if (++cnt == warningsLimit)
                    break;
            }
        }
    }
    IgniteDiagnosticPrepareContext diagCtx = cctx.kernalContext().cluster().diagnosticEnabled() ? new IgniteDiagnosticPrepareContext(cctx.localNodeId()) : null;
    if (diagCtx != null && exchFut != null)
        exchFut.addDiagnosticRequest(diagCtx);
    ExchangeFutureSet exchFuts = this.exchFuts;
    if (exchFuts != null) {
        U.warn(diagnosticLog, "Last " + DIAGNOSTIC_WARN_LIMIT + " exchange futures (total: " + exchFuts.size() + "):");
        if (DIAGNOSTIC_WARN_LIMIT > 0) {
            int cnt = 0;
            for (GridDhtPartitionsExchangeFuture fut : exchFuts.values()) {
                U.warn(diagnosticLog, ">>> " + fut.shortInfo());
                if (++cnt == DIAGNOSTIC_WARN_LIMIT)
                    break;
            }
        }
    }
    U.warn(diagnosticLog, "Latch manager state: " + latchMgr);
    dumpPendingObjects(exchTopVer, diagCtx);
    for (CacheGroupContext grp : cctx.cache().cacheGroups()) {
        GridCachePreloader preloader = grp.preloader();
        if (preloader != null)
            preloader.dumpDebugInfo();
    }
    cctx.affinity().dumpDebugInfo();
    StringBuilder pendingMsgs = new StringBuilder();
    cctx.io().dumpPendingMessages(pendingMsgs);
    if (pendingMsgs.length() > 0 && diagnosticLog.isInfoEnabled())
        diagnosticLog.info(pendingMsgs.toString());
    if (IgniteSystemProperties.getBoolean(IGNITE_IO_DUMP_ON_TIMEOUT, false))
        cctx.gridIO().dumpStats();
    if (IgniteSystemProperties.getBoolean(IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT, false))
        U.dumpThreads(diagnosticLog);
    if (diagCtx != null)
        diagCtx.send(cctx.kernalContext(), null);
}
Also used : GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) IgniteDiagnosticPrepareContext(org.apache.ignite.internal.IgniteDiagnosticPrepareContext) GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)

Example 3 with IgniteDiagnosticPrepareContext

use of org.apache.ignite.internal.IgniteDiagnosticPrepareContext in project ignite by apache.

the class IgniteDiagnosticMessagesTest method sendDiagnostic.

/**
 * @throws Exception If failed.
 */
private void sendDiagnostic() throws Exception {
    for (int i = 0; i < 5; i++) {
        IgniteKernal node = (IgniteKernal) ignite(i);
        for (int j = 0; j < 5; j++) {
            if (i != j) {
                ClusterNode dstNode = ignite(j).cluster().localNode();
                final GridFutureAdapter<String> fut = new GridFutureAdapter<>();
                IgniteDiagnosticPrepareContext ctx = new IgniteDiagnosticPrepareContext(node.localNodeId());
                ctx.basicInfo(dstNode.id(), "Test diagnostic");
                ctx.send(node.context(), new IgniteInClosure<IgniteInternalFuture<String>>() {

                    @Override
                    public void apply(IgniteInternalFuture<String> diagFut) {
                        try {
                            fut.onDone(diagFut.get());
                        } catch (Exception e) {
                            fut.onDone(e);
                        }
                    }
                });
                String msg = fut.get();
                String searchMsg = "General node info [id=" + dstNode.id() + ", client=" + dstNode.isClient() + ", discoTopVer=AffinityTopologyVersion [topVer=5, minorTopVer=";
                assertTrue("Unexpected message: " + msg, msg.contains("Test diagnostic") && msg.contains(searchMsg) && msg.contains("Partitions exchange info [readyVer=AffinityTopologyVersion [topVer=5, minorTopVer="));
            }
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteKernal(org.apache.ignite.internal.IgniteKernal) IgniteDiagnosticPrepareContext(org.apache.ignite.internal.IgniteDiagnosticPrepareContext) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture)

Aggregations

IgniteDiagnosticPrepareContext (org.apache.ignite.internal.IgniteDiagnosticPrepareContext)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 IgniteDiagnosticAware (org.apache.ignite.internal.IgniteDiagnosticAware)1 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)1 IgniteKernal (org.apache.ignite.internal.IgniteKernal)1 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)1 GridDhtPartitionsExchangeFuture (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture)1 IgniteInternalTx (org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx)1 IgniteTxManager (org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)1 GridStringBuilder (org.apache.ignite.internal.util.GridStringBuilder)1 GridFutureAdapter (org.apache.ignite.internal.util.future.GridFutureAdapter)1 GridPlainRunnable (org.apache.ignite.internal.util.lang.GridPlainRunnable)1