Github user poornachandra commented on a diff in the pull request:
https://github.com/apache/incubator-tephra/pull/22#discussion_r93238207
--- Diff: tephra-core/src/main/java/org/apache/tephra/util/TxUtils.java ---
@@ -163,8 +167,22 @@ public static long getPruneUpperBound(Transaction tx) {
long maxInvalidTx =
tx.getInvalids().length > 0 ?
tx.getInvalids()[tx.getInvalids().length - 1] : Transaction.NO_TX_IN_PROGRESS;
+
+ // An invalid transaction can be used up to its max lifetime for data
writes, hence we cannot prune an invalid
+ // transaction until it exhausts its max lifetime.
+ long elapsedTime = currentTimeMillis -
TxUtils.getTimestamp(maxInvalidTx);
+ long invalidTxBound;
+ if (elapsedTime > txMaxLifetimeMillis) {
+ // maxInvalidTx is past its max lifetime
+ invalidTxBound = maxInvalidTx;
+ } else {
+ // Reduce the lifetime of maxInvalidTx, so that it cannot be used
for any more writes
+ long remainingTime = txMaxLifetimeMillis - elapsedTime;
+ invalidTxBound = maxInvalidTx - remainingTime *
TxConstants.MAX_TX_PER_MS - 1;
--- End diff --
On further thought, we will need to compute inactive transaction bound
separately from prune upper bound.
Inactive transaction bound can be computed using just current time and tx
max lifetime as ` (currentTimeMillis - txMaxLifetimeMillis) *
TxConstants.MAX_TX_PER_MS - 1`.
However, prune upper bound is a record of what invalid data was removed
during a major compaction, and hence will need to use the invalid list and
in-progress list from the transaction snapshot used at the time of the major
compaction.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---