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-19846 IgniteTxAdapter initial cleanup #10806

Merged
merged 6 commits into from
Jun 30, 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 @@ -162,7 +162,6 @@ public GridDistributedTxRemoteAdapter(
ctx,
nodeId,
xidVer,
null,
Thread.currentThread().getId(),
sys,
plc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,6 @@ public void rollbackDhtLocal() throws IgniteCheckedException {
public IgniteInternalFuture<IgniteInternalTx> rollbackDhtLocalAsync() {
final GridDhtTxFinishFuture fut = new GridDhtTxFinishFuture<>(cctx, this, false);

rollbackFuture(fut);

cctx.mvcc().addFuture(fut, fut.futureId());

GridDhtTxPrepareFuture prepFut = this.prepFut;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4098,8 +4098,6 @@ public IgniteInternalFuture<IgniteInternalTx> rollbackNearTxLocalAsync(final boo
if (!FINISH_FUT_UPD.compareAndSet(this, null, fut = finishFuture(fastFinish = clearThreadMap && fastFinish(), false)))
return chainFinishFuture(finishFut, false, clearThreadMap, onTimeout);

rollbackFuture(fut);

if (!fastFinish) {
if (prepFut == null || prepFut.isDone()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,57 +138,57 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement

/** Transaction ID. */
@GridToStringInclude
protected GridCacheVersion xidVer;
protected final GridCacheVersion xidVer;

/** Entries write version. */
@GridToStringInclude
protected GridCacheVersion writeVer;
private GridCacheVersion writeVer;

/** Implicit flag. */
@GridToStringInclude
protected boolean implicit;
protected final boolean implicit;

/** Local flag. */
@GridToStringInclude
protected boolean loc;
private final boolean loc;

/** Thread ID. */
@GridToStringInclude
protected long threadId;

/** Transaction start time. */
@GridToStringInclude
protected long startTime = U.currentTimeMillis();
protected final long startTime = U.currentTimeMillis();

/** Transaction start time in nanoseconds to measure duration. */
protected long startTimeNanos;
private final long startTimeNanos;

/** Node ID. */
@GridToStringInclude
protected UUID nodeId;
protected final UUID nodeId;

/** Cache registry. */
@GridToStringExclude
protected GridCacheSharedContext<?, ?> cctx;
protected final GridCacheSharedContext<?, ?> cctx;

/** Need return value. */
protected boolean needRetVal;
private boolean needRetVal;

/** Isolation. */
@GridToStringInclude
protected TransactionIsolation isolation = READ_COMMITTED;
protected final TransactionIsolation isolation;

/** Concurrency. */
@GridToStringInclude
protected TransactionConcurrency concurrency = PESSIMISTIC;
protected final TransactionConcurrency concurrency;

/** Transaction timeout. */
@GridToStringInclude
protected long timeout;
private long timeout;

/** Deployment class loader id which will be used for deserialization of entries on a distributed task. */
@GridToStringExclude
protected IgniteUuid deploymentLdrId;
protected final IgniteUuid deploymentLdrId;

/** Invalidate flag. */
protected volatile boolean invalidate;
Expand All @@ -197,13 +197,13 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
private boolean sysInvalidate;

/** Internal flag. */
protected boolean internal;
private boolean internal;

/** System transaction flag. */
private boolean sys;
private final boolean sys;

/** IO policy. */
private byte plc;
private final byte plc;

/** One phase commit flag. */
protected boolean onePhaseCommit;
Expand Down Expand Up @@ -233,7 +233,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
private volatile boolean timedOut;

/** */
protected int txSize;
protected final int txSize;

/** */
@GridToStringExclude
Expand All @@ -247,19 +247,19 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
protected Map<UUID, Collection<UUID>> txNodes;

/** Subject ID initiated this transaction. */
protected UUID subjId;
private final UUID subjId;

/** Task name hash code. */
protected int taskNameHash;
private final int taskNameHash;

/** Task name. */
protected final String taskName;

/** Store used flag. */
protected boolean storeEnabled = true;
private boolean storeEnabled = true;

/** UUID to consistent id mapper. */
protected ConsistentIdMapper consistentIdMapper;
protected final ConsistentIdMapper consistentIdMapper;

/** Mvcc tx update snapshot. */
@GridToStringInclude
Expand All @@ -268,23 +268,9 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
/** Incremental snapshot ID. */
private @Nullable UUID incSnpId;

/** {@inheritDoc} */
@Override public UUID incrementalSnapshotId() {
return incSnpId;
}

/** {@inheritDoc} */
@Override public void incrementalSnapshotId(UUID id) {
incSnpId = id;
}

/** {@code True} if tx should skip adding itself to completed version map on finish. */
private boolean skipCompletedVers;

/** Rollback finish future. */
@GridToStringExclude
private volatile IgniteInternalFuture rollbackFut;

/** */
@SuppressWarnings("unused")
@GridToStringExclude
Expand Down Expand Up @@ -352,20 +338,18 @@ protected IgniteTxAdapter(
consistentIdMapper = new ConsistentIdMapper(cctx.discovery());

boolean needTaskName = cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ) ||
cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_PUT) ||
cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_REMOVED);
cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_PUT) ||
cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_REMOVED);

taskName = needTaskName ? cctx.kernalContext().task().resolveTaskName(taskNameHash) : null;

if (cctx.kernalContext().performanceStatistics().enabled())
startTimeNanos = System.nanoTime();
startTimeNanos = cctx.kernalContext().performanceStatistics().enabled() ? System.nanoTime() : -1;
}

/**
* @param cctx Cache registry.
* @param nodeId Node ID.
* @param xidVer Transaction ID.
* @param startVer Start version mark.
* @param threadId Thread ID.
* @param sys System transaction flag.
* @param plc IO policy.
Expand All @@ -378,7 +362,6 @@ protected IgniteTxAdapter(
GridCacheSharedContext<?, ?> cctx,
UUID nodeId,
GridCacheVersion xidVer,
GridCacheVersion startVer,
long threadId,
boolean sys,
byte plc,
Expand All @@ -401,6 +384,7 @@ protected IgniteTxAdapter(
this.txSize = txSize;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
this.deploymentLdrId = null;

implicit = false;
loc = false;
Expand All @@ -416,8 +400,17 @@ protected IgniteTxAdapter(

taskName = needTaskName ? cctx.kernalContext().task().resolveTaskName(taskNameHash) : null;

if (cctx.kernalContext().performanceStatistics().enabled())
startTimeNanos = System.nanoTime();
startTimeNanos = cctx.kernalContext().performanceStatistics().enabled() ? System.nanoTime() : -1;
}

/** {@inheritDoc} */
@Override public UUID incrementalSnapshotId() {
return incSnpId;
}

/** {@inheritDoc} */
@Override public void incrementalSnapshotId(UUID id) {
incSnpId = id;
}

/**
Expand Down Expand Up @@ -705,7 +698,7 @@ public boolean remote() {

/** {@inheritDoc} */
@Override public Map<Integer, Set<Integer>> invalidPartitions() {
return invalidParts == null ? Collections.<Integer, Set<Integer>>emptyMap() : invalidParts;
return invalidParts == null ? Collections.emptyMap() : invalidParts;
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -757,20 +750,6 @@ public void needReturnValue(boolean needRetVal) {
this.needRetVal = needRetVal;
}

/**
* @return Rollback future.
*/
public IgniteInternalFuture rollbackFuture() {
return rollbackFut;
}

/**
* @param fut Rollback future.
*/
public void rollbackFuture(IgniteInternalFuture fut) {
rollbackFut = fut;
}

/**
* Gets remaining allowed transaction time.
*
Expand Down Expand Up @@ -1152,16 +1131,20 @@ protected final boolean state(TransactionState state, boolean timedOut) {

break;
}

case SUSPENDED:
case PREPARING: {
valid = prev == ACTIVE;

break;
}

case PREPARED: {
valid = prev == PREPARING;

break;
}

case COMMITTING: {
valid = prev == PREPARED;

Expand Down Expand Up @@ -1207,12 +1190,6 @@ protected final boolean state(TransactionState state, boolean timedOut) {

break;
}

case SUSPENDED: {
valid = prev == ACTIVE;

break;
}
}

if (valid) {
Expand Down Expand Up @@ -1918,8 +1895,7 @@ protected boolean evictNearEntry(IgniteTxEntry e, boolean primaryOnly) {
if (log.isDebugEnabled())
log.debug("Evicting dht-local entry from near cache [entry=" + cached + ", tx=" + this + ']');

if (cached != null && cached.markObsolete(xidVer))
return true;
return cached.markObsolete(xidVer);
}

return false;
Expand Down Expand Up @@ -2028,7 +2004,7 @@ protected void applyTxSizes() {
private static class TxFinishFuture extends GridFutureAdapter<IgniteInternalTx> {
/** */
@GridToStringInclude
private IgniteTxAdapter tx;
private final IgniteTxAdapter tx;

/** */
private volatile long completionTime;
Expand Down