Skip to content

Commit

Permalink
IGNITE-20508 DeadlockDetectionManager removal (apache#10959)
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-vinogradov authored and J-Bakuli committed Nov 10, 2023
1 parent 7ec7514 commit e10bc1a
Show file tree
Hide file tree
Showing 27 changed files with 27 additions and 952 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.IgniteCodeGeneratingFail;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.mvcc.DeadlockProbe;
import org.apache.ignite.internal.processors.cache.mvcc.ProbedTx;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
Expand Down Expand Up @@ -173,9 +171,6 @@ public static void main(String[] args) throws Exception {

MessageCodeGenerator gen = new MessageCodeGenerator(srcDir);

gen.generateAndWrite(ProbedTx.class);
gen.generateAndWrite(DeadlockProbe.class);

// gen.generateAll(true);

// gen.generateAndWrite(GridCacheMessage.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
import java.io.Serializable;
import java.util.ArrayList;
import javax.cache.configuration.Factory;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.internal.util.TransientSerializable;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteExperimental;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
Expand Down Expand Up @@ -58,9 +56,6 @@ public class TransactionConfiguration implements Serializable {
/** Transaction timeout on partition map synchronization. */
public static final long TX_TIMEOUT_ON_PARTITION_MAP_EXCHANGE = 0;

/** Default timeout before starting deadlock detection. */
public static final long DFLT_DEADLOCK_TIMEOUT = 10_000;

/**
* Default size of pessimistic transactions log.
* @deprecated Pessimistic tx log linger property has no effect.
Expand All @@ -85,9 +80,6 @@ public class TransactionConfiguration implements Serializable {
*/
private volatile long txTimeoutOnPartitionMapExchange = TX_TIMEOUT_ON_PARTITION_MAP_EXCHANGE;

/** Timeout before starting deadlock detection. */
private long deadlockTimeout = DFLT_DEADLOCK_TIMEOUT;

/** Pessimistic tx log size. */
@Deprecated
private int pessimisticTxLogSize;
Expand Down Expand Up @@ -123,7 +115,6 @@ public TransactionConfiguration(TransactionConfiguration cfg) {
dfltIsolation = cfg.getDefaultTxIsolation();
dfltTxTimeout = cfg.getDefaultTxTimeout();
txTimeoutOnPartitionMapExchange = cfg.getTxTimeoutOnPartitionMapExchange();
deadlockTimeout = cfg.getDeadlockTimeout();
pessimisticTxLogLinger = cfg.getPessimisticTxLogLinger();
pessimisticTxLogSize = cfg.getPessimisticTxLogSize();
txSerEnabled = cfg.isTxSerializableEnabled();
Expand Down Expand Up @@ -260,44 +251,6 @@ public TransactionConfiguration setTxTimeoutOnPartitionMapExchange(long txTimeou
return this;
}

/**
* <b>This is an experimental feature. Transactional SQL is currently in a beta status.</b>
* <p>
* Transaction deadlocks occurred for caches configured with {@link CacheAtomicityMode#TRANSACTIONAL_SNAPSHOT}
* can be resolved automatically.
* <p>
* Deadlock detection starts when one transaction is waiting for an entry lock more than a timeout specified by
* this property.
* <p>
* Timeout is specified in milliseconds and {@code 0} means that automatic deadlock detection is disabled. Default
* value is defined by {@link #DFLT_DEADLOCK_TIMEOUT}.
*
* @return Timeout before starting deadlock detection.
*/
@IgniteExperimental
public long getDeadlockTimeout() {
return deadlockTimeout;
}

/**
* <b>This is an experimental feature. Transactional SQL is currently in a beta status.</b>
* <p>
* Sets a timeout before starting deadlock detection for caches configured with
* {@link CacheAtomicityMode#TRANSACTIONAL_SNAPSHOT}.
* <p>
* Timeout is specified in milliseconds and {@code 0} means that automatic deadlock detection is disabled. Default
* value is defined by {@link #DFLT_DEADLOCK_TIMEOUT}.
*
* @param deadlockTimeout Timeout value in milliseconds.
* @return {@code this} for chaining.
*/
@IgniteExperimental
public TransactionConfiguration setDeadlockTimeout(long deadlockTimeout) {
this.deadlockTimeout = deadlockTimeout;

return this;
}

/**
* Gets size of pessimistic transactions log stored on node in order to recover transaction commit if originating
* node has left grid before it has sent all messages to transaction nodes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_PORT_RANGE;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SHUTDOWN_POLICY;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SPI_CLASS;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_TX_CONFIG;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_TX_SERIALIZABLE_ENABLED;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME;
import static org.apache.ignite.internal.IgniteVersionUtils.BUILD_TSTAMP_STR;
import static org.apache.ignite.internal.IgniteVersionUtils.COPYRIGHT;
Expand Down Expand Up @@ -1695,7 +1695,7 @@ private void fillNodeAttributes(boolean notifyEnabled) throws IgniteCheckedExcep
addDataStorageConfigurationAttributes();

// Save transactions configuration.
add(ATTR_TX_CONFIG, cfg.getTransactionConfiguration());
add(ATTR_TX_SERIALIZABLE_ENABLED, cfg.getTransactionConfiguration().isTxSerializableEnabled());

// Supported features.
add(ATTR_IGNITE_FEATURES, IgniteFeatures.allFeatures());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public final class IgniteNodeAttributes {
public static final String ATTR_CACHE = ATTR_PREFIX + ".cache";

/** Internal attribute name constant. */
public static final String ATTR_TX_CONFIG = ATTR_PREFIX + ".tx";
public static final String ATTR_TX_SERIALIZABLE_ENABLED = ATTR_PREFIX + ".tx.serializable.enabled";

/** Internal attribute name constant. */
public static final String ATTR_JMX_PORT = ATTR_PREFIX + ".jmx.port";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.client.ClientClusterGroup;
import org.apache.ignite.client.ClientException;
import org.apache.ignite.client.ClientFeatureNotSupportedByServerException;
Expand Down Expand Up @@ -438,8 +439,14 @@ private Map<String, Object> readNodeAttributes(BinaryReaderExImpl reader) {

Map<String, Object> attrs = new HashMap<>(attrCnt);

for (int i = 0; i < attrCnt; i++)
attrs.put(reader.readString(), reader.readObjectDetached());
for (int i = 0; i < attrCnt; i++) {
try {
attrs.put(reader.readString(), reader.readObjectDetached());
}
catch (BinaryObjectException ignored) {
// Skipping deserialization issues related to the incompatible classes from different versions.
}
}

return attrs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxQueryResultsEnlistRequest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxQueryResultsEnlistResponse;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest;
import org.apache.ignite.internal.processors.cache.mvcc.DeadlockProbe;
import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs;
import org.apache.ignite.internal.processors.cache.mvcc.MvccVersionImpl;
import org.apache.ignite.internal.processors.cache.mvcc.ProbedTx;
import org.apache.ignite.internal.processors.cache.mvcc.msg.MvccAckRequestQueryCntr;
import org.apache.ignite.internal.processors.cache.mvcc.msg.MvccAckRequestQueryId;
import org.apache.ignite.internal.processors.cache.mvcc.msg.MvccAckRequestTx;
Expand Down Expand Up @@ -372,8 +370,6 @@ public class GridIoMessageFactory implements MessageFactoryProvider {
factory.register((short)167, ServiceDeploymentProcessId::new);
factory.register((short)168, ServiceSingleNodeDeploymentResultBatch::new);
factory.register((short)169, ServiceSingleNodeDeploymentResult::new);
factory.register((short)170, DeadlockProbe::new);
factory.register((short)171, ProbedTx::new);
factory.register(GridQueryKillRequest.TYPE_CODE, GridQueryKillRequest::new);
factory.register(GridQueryKillResponse.TYPE_CODE, GridQueryKillResponse::new);
factory.register(GridIoSecurityAwareMessage.TYPE_CODE, GridIoSecurityAwareMessage::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrManager;
import org.apache.ignite.internal.processors.cache.jta.CacheJtaManagerAdapter;
import org.apache.ignite.internal.processors.cache.mvcc.DeadlockDetectionManager;
import org.apache.ignite.internal.processors.cache.mvcc.MvccCachingManager;
import org.apache.ignite.internal.processors.cache.persistence.DataRegion;
import org.apache.ignite.internal.processors.cache.persistence.DatabaseLifecycleListener;
Expand Down Expand Up @@ -3077,8 +3076,6 @@ private GridCacheSharedContext createSharedContext(

MvccCachingManager mvccCachingMgr = new MvccCachingManager();

DeadlockDetectionManager deadlockDetectionMgr = new DeadlockDetectionManager();

CacheDiagnosticManager diagnosticMgr = new CacheDiagnosticManager();

return new GridCacheSharedContext(
Expand All @@ -3100,7 +3097,6 @@ private GridCacheSharedContext createSharedContext(
jta,
storeSesLsnrs,
mvccCachingMgr,
deadlockDetectionMgr,
diagnosticMgr,
transMgr
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.PartitionsEvictManager;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.jta.CacheJtaManagerAdapter;
import org.apache.ignite.internal.processors.cache.mvcc.DeadlockDetectionManager;
import org.apache.ignite.internal.processors.cache.mvcc.MvccCachingManager;
import org.apache.ignite.internal.processors.cache.mvcc.MvccProcessor;
import org.apache.ignite.internal.processors.cache.persistence.DataRegion;
Expand Down Expand Up @@ -141,9 +140,6 @@ public class GridCacheSharedContext<K, V> {
/** Mvcc caching manager. */
private MvccCachingManager mvccCachingMgr;

/** Deadlock detection manager. */
private DeadlockDetectionManager deadlockDetectionMgr;

/** Cache objects transformation manager. */
private CacheObjectTransformerManager transMgr;

Expand Down Expand Up @@ -213,7 +209,6 @@ public class GridCacheSharedContext<K, V> {
* @param jtaMgr JTA manager.
* @param storeSesLsnrs Store session listeners.
* @param mvccCachingMgr Mvcc caching manager.
* @param deadlockDetectionMgr Deadlock detection manager.
*/
public GridCacheSharedContext(
GridKernalContext kernalCtx,
Expand All @@ -234,7 +229,6 @@ public GridCacheSharedContext(
CacheJtaManagerAdapter jtaMgr,
Collection<CacheStoreSessionListener> storeSesLsnrs,
MvccCachingManager mvccCachingMgr,
DeadlockDetectionManager deadlockDetectionMgr,
CacheDiagnosticManager diagnosticMgr,
CacheObjectTransformerManager transMgr
) {
Expand All @@ -259,7 +253,6 @@ public GridCacheSharedContext(
ttlMgr,
evictMgr,
mvccCachingMgr,
deadlockDetectionMgr,
diagnosticMgr,
transMgr
);
Expand Down Expand Up @@ -439,7 +432,6 @@ void onReconnected(boolean active) throws IgniteCheckedException {
ttlMgr,
evictMgr,
mvccCachingMgr,
deadlockDetectionMgr,
diagnosticMgr,
transMgr
);
Expand Down Expand Up @@ -490,7 +482,6 @@ private void setManagers(
GridCacheSharedTtlCleanupManager ttlMgr,
PartitionsEvictManager evictMgr,
MvccCachingManager mvccCachingMgr,
DeadlockDetectionManager deadlockDetectionMgr,
CacheDiagnosticManager diagnosticMgr,
CacheObjectTransformerManager transMgr
) {
Expand All @@ -515,7 +506,6 @@ private void setManagers(
this.ttlMgr = add(mgrs, ttlMgr);
this.evictMgr = add(mgrs, evictMgr);
this.mvccCachingMgr = add(mgrs, mvccCachingMgr);
this.deadlockDetectionMgr = add(mgrs, deadlockDetectionMgr);
this.transMgr = add(mgrs, transMgr);
}

Expand Down Expand Up @@ -886,13 +876,6 @@ public CacheDiagnosticManager diagnostic() {
return diagnosticMgr;
}

/**
* @return Deadlock detection manager.
*/
public DeadlockDetectionManager deadlockDetectionMgr() {
return deadlockDetectionMgr;
}

/**
* @return Cache objects transformation manager.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import org.apache.ignite.spi.indexing.IndexingSpi;
import org.apache.ignite.spi.indexing.noop.NoopIndexingSpi;
import org.jetbrains.annotations.Nullable;

import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
Expand All @@ -81,7 +82,7 @@
import static org.apache.ignite.configuration.DeploymentMode.ISOLATED;
import static org.apache.ignite.configuration.DeploymentMode.PRIVATE;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_CONSISTENCY_CHECK_SKIPPED;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_TX_CONFIG;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_TX_SERIALIZABLE_ENABLED;
import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isDefaultDataRegionPersistent;
import static org.apache.ignite.internal.processors.security.SecurityUtils.nodeSecurityContext;

Expand Down Expand Up @@ -621,53 +622,20 @@ private static void checkTransactionConfiguration(
GridKernalContext ctx,
IgniteLogger log
) throws IgniteCheckedException {
TransactionConfiguration rmtTxCfg = rmt.attribute(ATTR_TX_CONFIG);
Boolean rmtTxSer = rmt.attribute(ATTR_TX_SERIALIZABLE_ENABLED);

if (rmtTxCfg != null) {
if (rmtTxSer != null) {
TransactionConfiguration locTxCfg = ctx.config().getTransactionConfiguration();

checkDeadlockDetectionConfig(rmt, rmtTxCfg, locTxCfg, log);

checkSerializableEnabledConfig(rmt, rmtTxCfg, locTxCfg);
}
}

/**
*
*/
private static void checkDeadlockDetectionConfig(
ClusterNode rmt,
TransactionConfiguration rmtTxCfg,
TransactionConfiguration locTxCfg,
IgniteLogger log
) {
boolean locDeadlockDetectionEnabled = locTxCfg.getDeadlockTimeout() > 0;
boolean rmtDeadlockDetectionEnabled = rmtTxCfg.getDeadlockTimeout() > 0;

if (locDeadlockDetectionEnabled != rmtDeadlockDetectionEnabled) {
U.warn(log, "Deadlock detection is enabled on one node and disabled on another. " +
"Disabled detection on one node can lead to undetected deadlocks. [rmtNodeId=" + rmt.id() +
", locDeadlockTimeout=" + locTxCfg.getDeadlockTimeout() +
", rmtDeadlockTimeout=" + rmtTxCfg.getDeadlockTimeout());
if (!rmtTxSer.equals(locTxCfg.isTxSerializableEnabled()))
throw new IgniteCheckedException("Serializable transactions enabled mismatch " +
"(fix txSerializableEnabled property or set -D" + IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true " +
"system property) [rmtNodeId=" + rmt.id() +
", locTxSerializableEnabled=" + locTxCfg.isTxSerializableEnabled() +
", rmtTxSerializableEnabled=" + rmtTxSer + ']');
}
}

/**
*
*/
private static void checkSerializableEnabledConfig(
ClusterNode rmt,
TransactionConfiguration rmtTxCfg,
TransactionConfiguration locTxCfg
) throws IgniteCheckedException {
if (locTxCfg.isTxSerializableEnabled() != rmtTxCfg.isTxSerializableEnabled())
throw new IgniteCheckedException("Serializable transactions enabled mismatch " +
"(fix txSerializableEnabled property or set -D" + IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true " +
"system property) [rmtNodeId=" + rmt.id() +
", locTxSerializableEnabled=" + locTxCfg.isTxSerializableEnabled() +
", rmtTxSerializableEnabled=" + rmtTxCfg.isTxSerializableEnabled() + ']');
}

/**
* @param rmt Remote node to check.
* @param ctx Context.
Expand Down
Loading

0 comments on commit e10bc1a

Please sign in to comment.