Skip to content

Commit 260359f

Browse files
authored
compatible with txn_file (#185)
Signed-off-by: yongman <yming0221@gmail.com>
1 parent 099157b commit 260359f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

include/pingcap/kv/LockResolver.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct Lock
6363
bool use_async_commit;
6464
uint64_t lock_for_update_ts;
6565
uint64_t min_commit_ts;
66+
bool is_txn_file;
6667

6768
explicit Lock(const ::kvrpcpb::LockInfo & l)
6869
: key(l.key())
@@ -74,6 +75,7 @@ struct Lock
7475
, use_async_commit(l.use_async_commit())
7576
, lock_for_update_ts(l.lock_for_update_ts())
7677
, min_commit_ts(l.min_commit_ts())
78+
, is_txn_file(l.is_txn_file())
7779
{}
7880

7981
std::string toDebugString() const;
@@ -287,7 +289,7 @@ class LockResolver
287289
TxnStatus getTxnStatusFromLock(Backoffer & bo, LockPtr lock, uint64_t caller_start_ts, bool force_sync_commit);
288290

289291

290-
TxnStatus getTxnStatus(Backoffer & bo, uint64_t txn_id, const std::string & primary, uint64_t caller_start_ts, uint64_t current_ts, bool rollback_if_not_exists, bool force_sync_commit);
292+
TxnStatus getTxnStatus(Backoffer & bo, uint64_t txn_id, const std::string & primary, uint64_t caller_start_ts, uint64_t current_ts, bool rollback_if_not_exists, bool force_sync_commit, bool is_txn_file);
291293

292294
Cluster * cluster;
293295
std::shared_mutex mu;

src/kv/LockResolver.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int64_t LockResolver::resolveLocksForWrite(Backoffer & bo, uint64_t caller_start
145145
return resolveLocks(bo, caller_start_ts, locks, ignored, true);
146146
}
147147

148-
TxnStatus LockResolver::getTxnStatus(Backoffer & bo, uint64_t txn_id, const std::string & primary, uint64_t caller_start_ts, uint64_t current_ts, bool rollback_if_not_exists, bool force_sync_commit)
148+
TxnStatus LockResolver::getTxnStatus(Backoffer & bo, uint64_t txn_id, const std::string & primary, uint64_t caller_start_ts, uint64_t current_ts, bool rollback_if_not_exists, bool force_sync_commit, bool is_txn_file)
149149
{
150150
TxnStatus * cached_status = getResolved(txn_id);
151151
if (cached_status != nullptr)
@@ -161,6 +161,7 @@ TxnStatus LockResolver::getTxnStatus(Backoffer & bo, uint64_t txn_id, const std:
161161
req.set_current_ts(current_ts);
162162
req.set_rollback_if_not_exist(rollback_if_not_exists);
163163
req.set_force_sync_commit(force_sync_commit);
164+
req.set_is_txn_file(is_txn_file);
164165
for (;;)
165166
{
166167
auto loc = cluster->region_cache->locateKey(bo, primary);
@@ -236,6 +237,7 @@ void LockResolver::resolveLock(Backoffer & bo, LockPtr lock, TxnStatus & status,
236237
log->information("resolveLock rollback lock " + lock->toDebugString());
237238
}
238239
}
240+
req.set_is_txn_file(lock->is_txn_file);
239241
RegionClient client(cluster, loc.region);
240242
kvrpcpb::ResolveLockResponse response;
241243
try
@@ -369,6 +371,7 @@ void LockResolver::resolveRegionLocks(
369371
auto * k = req.add_keys();
370372
*k = key;
371373
}
374+
req.set_is_txn_file(lock->is_txn_file);
372375

373376
RegionClient client(cluster, region_id);
374377
::kvrpcpb::ResolveLockResponse response;
@@ -497,7 +500,7 @@ TxnStatus LockResolver::getTxnStatusFromLock(Backoffer & bo, LockPtr lock, uint6
497500
{
498501
try
499502
{
500-
return getTxnStatus(bo, lock->txn_id, lock->primary, caller_start_ts, current_ts, rollback_if_not_exists, force_sync_commit);
503+
return getTxnStatus(bo, lock->txn_id, lock->primary, caller_start_ts, current_ts, rollback_if_not_exists, force_sync_commit, lock->is_txn_file);
501504
}
502505
catch (Exception & e)
503506
{

0 commit comments

Comments
 (0)