Search in sources :

Example 26 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class RegisteredQueryCursor method close.

/**
 * {@inheritDoc}
 */
@Override
public void close() {
    Span span = MTC.span();
    try (TraceSurroundings ignored = MTC.support(tracing.create(SQL_CURSOR_CLOSE, span != NoopSpan.INSTANCE ? span : qrySpan))) {
        super.close();
        unregisterQuery();
    } catch (Throwable th) {
        qrySpan.addTag(ERROR, th::getMessage);
        throw th;
    }
}
Also used : Span(org.apache.ignite.internal.processors.tracing.Span) NoopSpan(org.apache.ignite.internal.processors.tracing.NoopSpan) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)

Example 27 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class GridDhtTxFinishFuture method onDone.

/**
 * {@inheritDoc}
 */
@Override
public boolean onDone(IgniteInternalTx tx, Throwable err) {
    try (TraceSurroundings ignored = MTC.support(span)) {
        if (initialized() || err != null) {
            Throwable e = this.err;
            if (this.tx.onePhaseCommit() && (this.tx.state() == COMMITTING)) {
                try {
                    boolean nodeStopping = X.hasCause(err, NodeStoppingException.class);
                    this.tx.tmFinish(err == null, nodeStopping || cctx.kernalContext().failure().nodeStopping(), false);
                } catch (IgniteCheckedException finishErr) {
                    U.error(log, "Failed to finish tx: " + tx, e);
                    if (e == null)
                        e = finishErr;
                }
            }
            if (commit && e == null)
                e = this.tx.commitError();
            Throwable finishErr = e != null ? e : err;
            if (super.onDone(tx, finishErr)) {
                cctx.tm().mvccFinish(this.tx);
                if (finishErr == null)
                    finishErr = this.tx.commitError();
                if (this.tx.syncMode() != PRIMARY_SYNC)
                    this.tx.sendFinishReply(finishErr);
                if (!this.tx.txState().mvccEnabled() && !commit && shouldApplyCountersOnRollbackError(finishErr)) {
                    TxCounters txCounters = this.tx.txCounters(false);
                    if (txCounters != null) {
                        try {
                            cctx.tm().txHandler().applyPartitionsUpdatesCounters(txCounters.updateCounters(), true, true);
                        } catch (IgniteCheckedException e0) {
                            throw new IgniteException(e0);
                        }
                    }
                }
                // Don't forget to clean up.
                cctx.mvcc().removeFuture(futId);
                return true;
            }
        }
        return false;
    }
}
Also used : TxCounters(org.apache.ignite.internal.processors.cache.transactions.TxCounters) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)

Example 28 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class GridNearTxFinishFuture method finish.

/**
 * {@inheritDoc}
 */
@Override
public void finish(final boolean commit, final boolean clearThreadMap, final boolean onTimeout) {
    try (TraceSurroundings ignored = MTC.supportContinual(span = cctx.kernalContext().tracing().create(TX_NEAR_FINISH, MTC.span()))) {
        if (!cctx.mvcc().addFuture(this, futureId()))
            return;
        if (tx.onNeedCheckBackup()) {
            assert tx.onePhaseCommit();
            checkBackup();
            // If checkBackup is set, it means that primary node has crashed and we will not need to send
            // finish request to it, so we can mark future as initialized.
            markInitialized();
            return;
        }
        if (!commit && !clearThreadMap)
            rollbackAsyncSafe(onTimeout);
        else
            doFinish(commit, clearThreadMap);
    }
}
Also used : TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)

Example 29 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class GridNearTxLocal method enlistWrite.

/**
 * @param cacheCtx Cache context.
 * @param cacheKey Key to enlist.
 * @param val Value.
 * @param expiryPlc Explicitly specified expiry policy for entry.
 * @param entryProcessor Entry processor (for invoke operation).
 * @param invokeArgs Optional arguments for EntryProcessor.
 * @param retval Flag indicating whether a value should be returned.
 * @param lockOnly If {@code true}, then entry will be enlisted as noop.
 * @param filter User filters.
 * @param ret Return value.
 * @param skipStore Skip store flag.
 * @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
 * @param recovery Recovery flag.
 * @param dataCenterId Optional data center Id.
 * @return Future for entry values loading.
 */
private <K, V> IgniteInternalFuture<Void> enlistWrite(final GridCacheContext cacheCtx, @Nullable AffinityTopologyVersion entryTopVer, KeyCacheObject cacheKey, Object val, @Nullable ExpiryPolicy expiryPlc, @Nullable EntryProcessor<K, V, Object> entryProcessor, @Nullable Object[] invokeArgs, final boolean retval, boolean lockOnly, final CacheEntryPredicate[] filter, final GridCacheReturn ret, boolean skipStore, final boolean singleRmv, boolean keepBinary, boolean recovery, Byte dataCenterId) {
    try (TraceSurroundings ignored2 = MTC.support(context().kernalContext().tracing().create(TX_NEAR_ENLIST_WRITE, MTC.span()))) {
        GridFutureAdapter<Void> enlistFut = new GridFutureAdapter<>();
        try {
            if (!updateLockFuture(null, enlistFut))
                return finishFuture(enlistFut, timedOut() ? timeoutException() : rollbackException(), false);
            addActiveCache(cacheCtx, recovery);
            final boolean hasFilters = !F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter);
            final boolean needVal = singleRmv || retval || hasFilters;
            final boolean needReadVer = needVal && (serializable() && optimistic());
            if (entryProcessor != null)
                transform = true;
            GridCacheVersion drVer = dataCenterId != null ? cacheCtx.cache().nextVersion(dataCenterId) : null;
            boolean loadMissed = enlistWriteEntry(cacheCtx, entryTopVer, cacheKey, val, entryProcessor, invokeArgs, expiryPlc, retval, lockOnly, filter, /*drVer*/
            drVer, /*drTtl*/
            -1L, /*drExpireTime*/
            -1L, ret, /*enlisted*/
            null, skipStore, singleRmv, hasFilters, needVal, needReadVer, keepBinary, recovery);
            if (loadMissed) {
                AffinityTopologyVersion topVer = topologyVersionSnapshot();
                if (topVer == null)
                    topVer = entryTopVer;
                IgniteInternalFuture<Void> loadFut = loadMissing(cacheCtx, topVer != null ? topVer : topologyVersion(), Collections.singleton(cacheKey), filter, ret, needReadVer, singleRmv, hasFilters, /*read through*/
                (entryProcessor != null || cacheCtx.config().isLoadPreviousValue()) && !skipStore, retval, keepBinary, recovery, expiryPlc);
                loadFut.listen(new IgniteInClosure<IgniteInternalFuture<Void>>() {

                    @Override
                    public void apply(IgniteInternalFuture<Void> fut) {
                        try {
                            fut.get();
                            finishFuture(enlistFut, null, true);
                        } catch (IgniteCheckedException e) {
                            finishFuture(enlistFut, e, true);
                        }
                    }
                });
                return enlistFut;
            }
            finishFuture(enlistFut, null, true);
            return enlistFut;
        } catch (IgniteCheckedException e) {
            return finishFuture(enlistFut, e, true);
        }
    }
}
Also used : GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)

Example 30 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class IgniteTxHandler method processDhtTxPrepareResponse.

/**
 * @param nodeId Node ID.
 * @param res Response.
 */
private void processDhtTxPrepareResponse(UUID nodeId, GridDhtTxPrepareResponse res) {
    try (TraceSurroundings ignored = MTC.support(ctx.kernalContext().tracing().create(TX_PROCESS_DHT_PREPARE_RESP, MTC.span()))) {
        GridDhtTxPrepareFuture fut = (GridDhtTxPrepareFuture) ctx.mvcc().versionedFuture(res.version(), res.futureId());
        if (fut == null) {
            if (txPrepareMsgLog.isDebugEnabled()) {
                txPrepareMsgLog.debug("Failed to find future for dht prepare response [txId=null" + ", dhtTxId=" + res.version() + ", node=" + nodeId + ", res=" + res + ']');
            }
            return;
        } else if (txPrepareMsgLog.isDebugEnabled())
            txPrepareMsgLog.debug("Received dht prepare response [txId=" + fut.tx().nearXidVersion() + ", node=" + nodeId + ']');
        IgniteInternalTx tx = fut.tx();
        assert tx != null;
        res.txState(tx.txState());
        fut.onResult(nodeId, res);
    }
}
Also used : GridDhtTxPrepareFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)

Aggregations

TraceSurroundings (org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)49 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)18 QueryCancelledException (org.apache.ignite.cache.query.QueryCancelledException)11 SQLException (java.sql.SQLException)10 IgniteException (org.apache.ignite.IgniteException)10 ArrayList (java.util.ArrayList)9 CacheException (javax.cache.CacheException)8 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)7 List (java.util.List)6 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)6 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)6 Collections.singletonList (java.util.Collections.singletonList)5 ClusterTopologyServerNotFoundException (org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException)5 BatchUpdateException (java.sql.BatchUpdateException)4 CacheServerNotFoundException (org.apache.ignite.cache.CacheServerNotFoundException)4 QueryRetryException (org.apache.ignite.cache.query.QueryRetryException)4 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)4 IgniteClusterReadOnlyException (org.apache.ignite.internal.processors.cache.distributed.dht.IgniteClusterReadOnlyException)4 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)4 QueryContext (org.apache.ignite.internal.processors.query.h2.opt.QueryContext)4