-
Notifications
You must be signed in to change notification settings - Fork 102
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-24242 Add RO/RW Transaction Timeout configuration schema #5093
Changes from 1 commit
68f1fa8
2e7c24c
c4fcc59
03a0274
7dcb643
1e21f92
a34ded1
9b6203a
17f37e4
4340ec3
db2fcef
71ac52d
ba756bc
c05476d
fa7f5df
cc9cb48
ae00d30
e1ee039
2f1e409
c0b0e40
2f13beb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,8 +198,9 @@ public class InternalTableImpl implements InternalTable { | |
/** Map update guarded by {@link #updatePartitionMapsMux}. */ | ||
private volatile Int2ObjectMap<PendingComparableValuesTracker<Long, Void>> storageIndexTrackerByPartitionId = emptyMap(); | ||
|
||
/** Implicit transaction timeout. */ | ||
private final long implicitTransactionTimeout; | ||
private final long roTransactionTimeout; | ||
|
||
private final long rwTransactionTimeout; | ||
rpuch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** Attempts to take lock. */ | ||
private final int attemptsObtainLock; | ||
|
@@ -218,7 +219,8 @@ public class InternalTableImpl implements InternalTable { | |
* @param clockService A hybrid logical clock service. | ||
* @param placementDriver Placement driver. | ||
* @param transactionInflights Transaction inflights. | ||
* @param implicitTransactionTimeout Implicit transaction timeout. | ||
* @param roTransactionTimeout Read-only transaction timeout. | ||
* @param rwTransactionTimeout RW transaction timeout. | ||
* @param attemptsObtainLock Attempts to take lock. | ||
*/ | ||
public InternalTableImpl( | ||
|
@@ -234,7 +236,8 @@ public InternalTableImpl( | |
HybridTimestampTracker observableTimestampTracker, | ||
PlacementDriver placementDriver, | ||
TransactionInflights transactionInflights, | ||
long implicitTransactionTimeout, | ||
long roTransactionTimeout, | ||
long rwTransactionTimeout, | ||
int attemptsObtainLock, | ||
Supplier<ScheduledExecutorService> streamerFlushExecutor, | ||
StreamerReceiverRunner streamerReceiverRunner | ||
|
@@ -251,7 +254,8 @@ public InternalTableImpl( | |
this.observableTimestampTracker = observableTimestampTracker; | ||
this.placementDriver = placementDriver; | ||
this.transactionInflights = transactionInflights; | ||
this.implicitTransactionTimeout = implicitTransactionTimeout; | ||
this.roTransactionTimeout = roTransactionTimeout; | ||
this.rwTransactionTimeout = rwTransactionTimeout; | ||
this.attemptsObtainLock = attemptsObtainLock; | ||
this.streamerFlushExecutor = streamerFlushExecutor; | ||
this.streamerReceiverRunner = streamerReceiverRunner; | ||
|
@@ -368,9 +372,11 @@ private <R> CompletableFuture<R> enlistInTx( | |
return postEnlist(fut, false, actualTx, actualTx.implicit()).handle((r, e) -> { | ||
if (e != null) { | ||
if (actualTx.implicit()) { | ||
long timeout = actualTx.isReadOnly() ? roTransactionTimeout : rwTransactionTimeout; | ||
|
||
long ts = (txStartTs == null) ? actualTx.startTimestamp().getPhysical() : txStartTs; | ||
|
||
if (exceptionAllowsImplicitTxRetry(e) && coarseCurrentTimeMillis() - ts < implicitTransactionTimeout) { | ||
if (exceptionAllowsImplicitTxRetry(e) && coarseCurrentTimeMillis() - ts < timeout) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about extracting the |
||
return enlistInTx(row, null, fac, noWriteChecker, ts); | ||
} | ||
} | ||
|
@@ -486,9 +492,11 @@ private <T> CompletableFuture<T> enlistInTx( | |
return postEnlist(fut, actualTx.implicit() && !singlePart, actualTx, full).handle((r, e) -> { | ||
if (e != null) { | ||
if (actualTx.implicit()) { | ||
long timeout = actualTx.isReadOnly() ? roTransactionTimeout : rwTransactionTimeout; | ||
|
||
long ts = (txStartTs == null) ? actualTx.startTimestamp().getPhysical() : txStartTs; | ||
|
||
if (exceptionAllowsImplicitTxRetry(e) && coarseCurrentTimeMillis() - ts < implicitTransactionTimeout) { | ||
if (exceptionAllowsImplicitTxRetry(e) && coarseCurrentTimeMillis() - ts < timeout) { | ||
return enlistInTx(keyRows, null, fac, reducer, noOpChecker, ts); | ||
} | ||
} | ||
|
@@ -1185,9 +1193,11 @@ private CompletableFuture<Void> updateAllWithRetry( | |
// Will be finished in one RTT. | ||
return postEnlist(fut, false, tx, true).handle((r, e) -> { | ||
if (e != null) { | ||
long timeout = tx.isReadOnly() ? roTransactionTimeout : rwTransactionTimeout; | ||
|
||
long ts = (txStartTs == null) ? tx.startTimestamp().getPhysical() : txStartTs; | ||
|
||
if (exceptionAllowsImplicitTxRetry(e) && coarseCurrentTimeMillis() - ts < implicitTransactionTimeout) { | ||
if (exceptionAllowsImplicitTxRetry(e) && coarseCurrentTimeMillis() - ts < timeout) { | ||
return updateAllWithRetry(rows, deleted, partition, ts); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,29 @@ public class TransactionConfigurationSchema { | |
@Value(hasDefault = true) | ||
public final long timeout = 10_000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still looks like a breaking change. Let's consult @ptupitsyn whether we are allowed to directly remove a configuration property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. But why should we consult Pavel about changing the property we've added a couple of weeks ago? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because 3.0.0 already contains |
||
|
||
/** Timeout for implicit transactions (milliseconds). */ | ||
@Range(min = 1) | ||
@Value(hasDefault = true) | ||
public final long implicitTransactionTimeout = 3_000; | ||
public final long minRoTimeout = 1; | ||
rpuch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@Range(min = 1) | ||
@Value(hasDefault = true) | ||
public final long maxRoTimeout = Long.MAX_VALUE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why it's not equal to dataAvailabilityTime? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (deleted as irrelevant) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. property deleted There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Will drop these properties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and there: for such properties it's reasonable to have milis(or any other) suffix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a proposal to switch duration-related properties type to My comment only makes sense if we still want to have that feature in the configuration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. property deleted |
||
|
||
@Range(min = 1) | ||
@Value(hasDefault = true) | ||
public final long minRwTimeout = 1; | ||
|
||
@Range(min = 1) | ||
@Value(hasDefault = true) | ||
public final long maxRwTimeout = Long.MAX_VALUE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it too much for default max value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. property deleted |
||
|
||
@Range(min = 1) | ||
@Value(hasDefault = true) | ||
public final long roTimeout = 10_000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How these defaults are calculated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good suggestion. |
||
|
||
@Range(min = 1) | ||
@Value(hasDefault = true) | ||
public final long rwTimeout = 3_000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already But if it's removed, it's a breaking change (as 3.0 code freeze has already happened) and it should be handled in a different way, probably by declaring it as deprecated and, maybe, using the existing value for some time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we still can do breaking changes in configuration APIs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
/** A transaction tries to take lock several times until it throws an exception {@lonk org.apache.ignite.tx.TransactionException}. */ | ||
@Range(min = 0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tx timeout is tx specific attribute, meaning that tx1 will have 100ms as timeout and tx2 that is running at the same time 2000ms. In that case why
roTransactionTimeout
andrwTransactionTimeout
are here?Besides that, it's just an encapsulation leak - simply TableManager should not know about such things.
I'd rather say that on tx creation we should populate TransacionOptions with default timeout from cfg if it's not specified by the user and within tx flow use timeout from the tx context - no need to propagate txTimeout to InternalTableImpl etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you agree that
implicitTransactionTimeout
should be removed with this PR? If yes, then it is clear why these options are there. If we should keepimplicitTransactionTimeout
then, probably, I should rollback the change.I suppose we should remove
implicitTransactionTimeout
and refactorTableManager
as you suggested. Am I right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to remove implicitTransactionTimeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought these properties define default TX timeouts. A default is global and not specific to a transaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.