Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-20433 cctx.mvccEnabled() removal #10938

Merged
merged 27 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,6 @@ private void handle0(AlterTableDropCommand cmd) throws IgniteCheckedException {

assert cctx != null;

if (cctx.mvccEnabled()) {
throw new IgniteSQLException("Cannot drop column(s) with enabled MVCC. " +
"Operation is unsupported at the moment.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
}

if (QueryUtils.isSqlType(typeDesc.valueClass())) {
throw new SchemaOperationException("Cannot drop column(s) because table was created " +
"with WRAP_VALUE=false option.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public InlineIndexImpl(GridCacheContext<?, ?> cctx, SortedIndexDefinition def, I

/** */
private boolean isSingleRowLookup(IndexRow lower, IndexRow upper) throws IgniteCheckedException {
return !cctx.mvccEnabled() && def.primary() && lower != null && isFullSchemaSearch(lower) && checkRowsTheSame(lower, upper);
return def.primary() && lower != null && isFullSchemaSearch(lower) && checkRowsTheSame(lower, upper);
}

/**
Expand Down Expand Up @@ -475,8 +475,6 @@ private InlineTreeFilterClosure filterClosure(IndexQueryContext qryCtx) {

MvccSnapshot v = qryCtx.mvccSnapshot();

assert !cctx.mvccEnabled() || v != null;

if (cacheFilter == null && v == null && qryCtx.rowFilter() == null)
return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.PartitionUpdateCounter;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker;
import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot;
import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils;
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore;
Expand Down Expand Up @@ -535,24 +532,7 @@ private Map<PartitionKey, ValidateIndexesPartitionResult> processPartition(

partRes = new ValidateIndexesPartitionResult();

boolean hasMvcc = grpCtx.caches().stream().anyMatch(GridCacheContext::mvccEnabled);

if (hasMvcc) {
for (GridCacheContext<?, ?> context : grpCtx.caches()) {
IndexQueryContext qryCtx = mvccQueryContext(context);

GridIterator<CacheDataRow> iterator = grpCtx.offheap().cachePartitionIterator(
context.cacheId(),
part.id(),
qryCtx.mvccSnapshot(),
null
);

processPartIterator(grpCtx, partRes, qryCtx, iterator);
}
}
else
processPartIterator(grpCtx, partRes, null, grpCtx.offheap().partitionIterator(part.id()));
processPartIterator(grpCtx, partRes, null, grpCtx.offheap().partitionIterator(part.id()));

PartitionUpdateCounter updateCntrAfter = part.dataStore().partUpdateCounter();

Expand Down Expand Up @@ -702,27 +682,6 @@ else if (current++ % checkThrough > 0)
}
}

/**
* Get QueryContext for MVCC snapshot.
*
* @param cctx Cache context.
* @return QueryContext for MVCC snapshot.
* @throws IgniteCheckedException If failed.
*/
private IndexQueryContext mvccQueryContext(GridCacheContext<?, ?> cctx) throws IgniteCheckedException {
boolean mvccEnabled = cctx.mvccEnabled();

if (mvccEnabled) {
MvccQueryTracker tracker = MvccUtils.mvccTracker(cctx, true);

MvccSnapshot mvccSnapshot = tracker.snapshot();

return new IndexQueryContext(cacheName -> null, null, mvccSnapshot);
}

return null;
}

/**
*
*/
Expand Down Expand Up @@ -791,7 +750,7 @@ private Map<String, ValidateIndexesPartitionResult> processIndex(
GridCursor<IndexRow> cursor = null;

try {
cursor = idx.find(null, null, true, true, mvccQueryContext(cacheCtxWithIdx.get1()));
cursor = idx.find(null, null, true, true, null);

if (cursor == null)
throw new IgniteCheckedException("Can't iterate through index: " + idx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ protected CdcCacheDataResendJob(CdcResendCommandArg arg, AffinityTopologyVersion
", dataRegionName=" + cache.context().dataRegion().config().getName() + ']');
}

if (cache.context().mvccEnabled())
throw new UnsupportedOperationException("The TRANSACTIONAL_SNAPSHOT mode is not supported.");

caches.add(cache);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ public class IndexesRebuildTask {
boolean recreate = pageStore == null || !pageStore.hasIndexStore(cctx.groupId());

if (recreate) {
boolean mvccEnabled = cctx.mvccEnabled();

// If there are no index store, rebuild all indexes.
clo = row -> cctx.queries().store(row, null, mvccEnabled);
clo = row -> cctx.queries().store(row, null, false);
}
else {
Collection<InlineIndex> toRebuild = cctx.kernalContext().indexProcessor().treeIndexes(cctx.name(), !force);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.internal.AsyncSupportAdapter;
import org.apache.ignite.internal.GridKernalState;
import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.lang.IgniteBiPredicate;
Expand Down Expand Up @@ -145,8 +144,6 @@ public void setCacheManager(org.apache.ignite.cache.CacheManager cacheMgr) {
CacheOperationGate opGate = onEnter();

try {
MvccUtils.verifyMvccOperationSupport(delegate.context(), "withExpiryPolicy");

return new GatewayProtectedCacheProxy<>(delegate, opCtx.withExpiryPolicy(plc), lock);
}
finally {
Expand Down Expand Up @@ -239,11 +236,6 @@ public void setCacheManager(org.apache.ignite.cache.CacheManager cacheMgr) {
CacheOperationGate opGate = onEnter();

try {
if (context().mvccEnabled()) {
throw new UnsupportedOperationException(
"The TRANSACTIONAL_SNAPSHOT mode is incompatible with the read-repair feature.");
}

if (context().isNear())
throw new UnsupportedOperationException("Read-repair is incompatible with near caches.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
import org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteConsistencyViolationException;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot;
import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils;
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
Expand Down Expand Up @@ -176,7 +175,6 @@
import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;

/**
Expand Down Expand Up @@ -767,16 +765,10 @@ public void onKernalStop() {

IgniteCacheOffheapManager offheapMgr = ctx.isNear() ? ctx.near().dht().context().offheap() : ctx.offheap();

MvccSnapshot mvccSnapshot = ctx.mvccEnabled() ? MvccUtils.MVCC_MAX_SNAPSHOT : null;

its.add(offheapMgr.cacheEntriesIterator(ctx, modes.primary, modes.backup, topVer, ctx.keepBinary(),
mvccSnapshot, null));
its.add(offheapMgr.cacheEntriesIterator(ctx, modes.primary, modes.backup, topVer, ctx.keepBinary(), null, null));
}
}
else if (modes.heap) {
if (ctx.mvccEnabled())
return F.emptyIterator();

if (modes.near && ctx.isNear())
its.add(ctx.near().nearEntries().iterator());

Expand Down Expand Up @@ -876,9 +868,7 @@ else if (modes.heap) {
ctx.shared().database().checkpointReadLock();

try {
cacheVal = ctx.mvccEnabled()
? e.mvccPeek(modes.heap && !modes.offheap)
: e.peek(modes.heap, modes.offheap, topVer, null);
cacheVal = e.peek(modes.heap, modes.offheap, topVer, null);
}
catch (GridCacheEntryRemovedException ignore) {
if (log.isDebugEnabled())
Expand Down Expand Up @@ -1065,9 +1055,6 @@ public List<GridCacheClearAllRunnable<K, V>> splitClearLocally(boolean srv, bool
@Override public void clearLocally(boolean srv, boolean near, boolean readers) {
ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);

//TODO IGNITE-7952
MvccUtils.verifyMvccOperationSupport(ctx, "Clear");

List<GridCacheClearAllRunnable<K, V>> jobs = splitClearLocally(srv, near, readers);

if (!F.isEmpty(jobs)) {
Expand Down Expand Up @@ -1138,9 +1125,6 @@ public List<GridCacheClearAllRunnable<K, V>> splitClearLocally(boolean srv, bool
* @throws IgniteCheckedException In case of error.
*/
private void clear(@Nullable Set<? extends K> keys) throws IgniteCheckedException {
//TODO IGNITE-7952
MvccUtils.verifyMvccOperationSupport(ctx, "Clear");

ctx.shared().cache().checkReadOnlyState("clear", ctx.config());

executeClearTask(keys, false).get();
Expand All @@ -1152,9 +1136,6 @@ private void clear(@Nullable Set<? extends K> keys) throws IgniteCheckedExceptio
* @return Future.
*/
private IgniteInternalFuture<?> clearAsync(@Nullable final Set<? extends K> keys) {
//TODO IGNITE-7952
MvccUtils.verifyMvccOperationSupport(ctx, "Clear");

ctx.shared().cache().checkReadOnlyState("clear", ctx.config());

return executeClearTask(keys, false).chainCompose(fut -> executeClearTask(keys, true));
Expand Down Expand Up @@ -1216,9 +1197,6 @@ public void clearLocally(Collection<KeyCacheObject> keys, boolean readers) {
if (F.isEmpty(keys))
return;

//TODO IGNITE-7952
MvccUtils.verifyMvccOperationSupport(ctx, "Clear");

GridCacheVersion obsoleteVer = nextVersion();

for (KeyCacheObject key : keys) {
Expand Down Expand Up @@ -1948,8 +1926,8 @@ protected final <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(
tx = checkCurrentTx();
}

if (ctx.mvccEnabled() || tx == null || tx.implicit()) {
assert (mvccSnapshot == null) == !ctx.mvccEnabled();
if (tx == null || tx.implicit()) {
assert mvccSnapshot == null;

Map<KeyCacheObject, EntryGetResult> misses = null;

Expand Down Expand Up @@ -2304,10 +2282,7 @@ else if (storeEnabled)

/** */
protected GridNearTxLocal checkCurrentTx() {
if (!ctx.mvccEnabled())
return ctx.tm().threadLocalTx(ctx);

return MvccUtils.tx(ctx.kernalContext(), null);
return ctx.tm().threadLocalTx(ctx);
}

/**
Expand Down Expand Up @@ -3486,9 +3461,6 @@ public CacheMetricsImpl metrics0() {
if (F.isEmpty(keys))
return true;

//TODO: IGNITE-9324: add explicit locks support.
MvccUtils.verifyMvccOperationSupport(ctx, "Lock");

IgniteInternalFuture<Boolean> fut = lockAllAsync(keys, timeout);

boolean isInterrupted = false;
Expand Down Expand Up @@ -3530,9 +3502,6 @@ public CacheMetricsImpl metrics0() {
@Override public IgniteInternalFuture<Boolean> lockAsync(K key, long timeout) {
A.notNull(key, "key");

//TODO: IGNITE-9324: add explicit locks support.
MvccUtils.verifyMvccOperationSupport(ctx, "Lock");

return lockAllAsync(Collections.singletonList(key), timeout);
}

Expand Down Expand Up @@ -3633,9 +3602,6 @@ protected void checkJta() throws IgniteCheckedException {
/** {@inheritDoc} */
@Override public void localLoadCache(final IgniteBiPredicate<K, V> p, Object[] args)
throws IgniteCheckedException {
//TODO IGNITE-7954
MvccUtils.verifyMvccOperationSupport(ctx, "Load");

final boolean replicate = ctx.isDrEnabled();
final AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();

Expand Down Expand Up @@ -3771,9 +3737,6 @@ public IgniteInternalFuture<?> loadAll(
for (Object key : keys)
A.notNull(key, "key");

//TODO IGNITE-7954
MvccUtils.verifyMvccOperationSupport(ctx, "Load");

CacheOperationContext opCtx = ctx.operationContextPerCall();

ExpiryPolicy plc = opCtx != null ? opCtx.expiry() : null;
Expand Down Expand Up @@ -3845,9 +3808,6 @@ private void localLoadAndUpdate(final Collection<? extends K> keys) throws Ignit
*/
public void localLoad(Collection<? extends K> keys, @Nullable ExpiryPolicy plc, final boolean keepBinary)
throws IgniteCheckedException {
//TODO IGNITE-7954
MvccUtils.verifyMvccOperationSupport(ctx, "Load");

final boolean replicate = ctx.isDrEnabled();
final AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();

Expand Down Expand Up @@ -3918,9 +3878,6 @@ IgniteInternalFuture<?> globalLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p

assert !F.isEmpty(nodes) : "There are not datanodes fo cache: " + ctx.name();

//TODO IGNITE-7954
MvccUtils.verifyMvccOperationSupport(ctx, "Load");

final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();

IgniteInternalFuture<?> fut = ctx.kernalContext().closure().callAsync(
Expand Down Expand Up @@ -4245,11 +4202,11 @@ public void awaitLastFut() {
true,
op.single(),
ctx.systemTx() ? ctx : null,
ctx.mvccEnabled() ? PESSIMISTIC : OPTIMISTIC,
ctx.mvccEnabled() ? REPEATABLE_READ : READ_COMMITTED,
OPTIMISTIC,
READ_COMMITTED,
tCfg.getDefaultTxTimeout(),
!ctx.skipStore(),
ctx.mvccEnabled(),
false,
0,
null
);
Expand Down Expand Up @@ -4363,11 +4320,11 @@ private <T> IgniteInternalFuture<T> asyncOp(final AsyncOp<T> op) {
true,
op.single(),
ctx.systemTx() ? ctx : null,
ctx.mvccEnabled() ? PESSIMISTIC : OPTIMISTIC,
ctx.mvccEnabled() ? REPEATABLE_READ : READ_COMMITTED,
OPTIMISTIC,
READ_COMMITTED,
txCfg.getDefaultTxTimeout(),
!skipStore,
ctx.mvccEnabled(),
false,
0,
null);

Expand Down Expand Up @@ -4635,9 +4592,6 @@ protected Object readResolve() throws ObjectStreamException {
private boolean clearLocally0(K key, boolean readers) {
ctx.shared().cache().checkReadOnlyState("clear", ctx.config());

//TODO IGNITE-7952
MvccUtils.verifyMvccOperationSupport(ctx, "Clear");

ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);

GridCacheVersion obsoleteVer = nextVersion();
Expand Down Expand Up @@ -4669,9 +4623,6 @@ private boolean clearLocally0(K key, boolean readers) {
@Override public boolean evict(K key) {
A.notNull(key, "key");

//TODO IGNITE-7956
MvccUtils.verifyMvccOperationSupport(ctx, "Evict");

return evictx(key, nextVersion(), CU.empty0());
}

Expand All @@ -4682,9 +4633,6 @@ private boolean clearLocally0(K key, boolean readers) {
if (F.isEmpty(keys))
return;

//TODO IGNITE-7956
MvccUtils.verifyMvccOperationSupport(ctx, "Evict");

GridCacheVersion obsoleteVer = nextVersion();

try {
Expand Down Expand Up @@ -5392,11 +5340,11 @@ public void execute(boolean retry) {
true,
op.single(),
ctx.systemTx() ? ctx : null,
ctx.mvccEnabled() ? PESSIMISTIC : OPTIMISTIC,
ctx.mvccEnabled() ? REPEATABLE_READ : READ_COMMITTED,
OPTIMISTIC,
READ_COMMITTED,
CU.transactionConfiguration(ctx, ctx.kernalContext().config()).getDefaultTxTimeout(),
opCtx == null || !opCtx.skipStore(),
ctx.mvccEnabled(),
false,
0,
null);

Expand Down
Loading