Skip to content

Commit 776313f

Browse files
authored
optimize ttl (#2669) (#2672)
1 parent 56ebcc5 commit 776313f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

tikv-client/src/main/java/com/pingcap/tikv/TwoPhaseCommitter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,14 @@ public class TwoPhaseCommitter {
8282
private final ExecutorService executorService;
8383

8484
public TwoPhaseCommitter(TiConfiguration conf, long startTime) {
85+
this(conf, startTime, DEFAULT_BATCH_WRITE_LOCK_TTL);
86+
}
87+
88+
public TwoPhaseCommitter(TiConfiguration conf, long startTime, long lockTTL) {
8589
this.kvClient = TiSession.getInstance(conf).createTxnClient();
8690
this.regionManager = kvClient.getRegionManager();
8791
this.startTs = startTime;
88-
this.lockTTL = DEFAULT_BATCH_WRITE_LOCK_TTL;
92+
this.lockTTL = lockTTL;
8993
this.retryCommitSecondaryKeys = true;
9094
this.txnPrewriteBatchSize = TXN_COMMIT_BATCH_SIZE;
9195
this.txnCommitBatchSize = TXN_COMMIT_BATCH_SIZE;

tikv-client/src/main/java/com/pingcap/tikv/allocator/RowIDAllocator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public final class RowIDAllocator implements Serializable {
6161
private final long step;
6262
private long end;
6363
private TiTimestamp timestamp;
64+
private final long RowIDAllocatorTTL = 10000;
6465

6566
private static final Logger LOG = LoggerFactory.getLogger(RowIDAllocator.class);
6667

@@ -141,8 +142,10 @@ private void set(@Nonnull List<BytePairWrapper> pairs, @Nonnull TiTimestamp time
141142
if (!iterator.hasNext()) {
142143
return;
143144
}
145+
144146
TiSession session = TiSession.getInstance(conf);
145-
TwoPhaseCommitter twoPhaseCommitter = new TwoPhaseCommitter(conf, timestamp.getVersion());
147+
TwoPhaseCommitter twoPhaseCommitter =
148+
new TwoPhaseCommitter(conf, timestamp.getVersion(), RowIDAllocatorTTL);
146149
BytePairWrapper primaryPair = iterator.next();
147150
twoPhaseCommitter.prewritePrimaryKey(
148151
ConcreteBackOffer.newCustomBackOff(BackOffer.PREWRITE_MAX_BACKOFF),

0 commit comments

Comments
 (0)