Repository: tikv/tikv
File: src/storage/txn/actions/commit.rs (Rust)

Code before:
            // The primary key should not collect mvcc because it is an expected case.
            false,
        );
        check_commit_ts_expired_err(
            must_err(
                &mut engine,
                k2,
                ts(10, 0),
                ts(15, 0),
                Some(CommitRole::Secondary),
            ),
            k2,
            ts(10, 0),
            ts(15, 0),
            ts(20, 1),
            // The secondary key should not collect mvcc because it may be a bug.
            true,
        );
        check_commit_ts_expired_err(
            must_err(&mut engine, k2, ts(10, 0), ts(20, 0), None),
            k2,
            ts(10, 0),
            ts(20, 0),
            ts(20, 1),
            // The secondary key should not collect mvcc because it may be a bug.
            // Although the commit role is none, we can get it from the lock.
            true,
        );
        must_succeed(&mut engine, k, ts(10, 0), ts(20, 1));

        must_prewrite_put_for_large_txn(&mut engine, k, v, k, ts(30, 0), 100, 0);
        check_txn_status::tests::must_success(
            &mut engine,
            k,
            ts(30, 0),
            ts(40, 0),
            ts(40, 0),
            true,
            false,
            false,
            uncommitted(100, ts(40, 1)),
        );
        must_succeed(&mut engine, k, ts(30, 0), ts(50, 0));

        // If the min_commit_ts of the pessimistic lock is greater than prewrite's, use
        // it.
        must_acquire_pessimistic_lock_for_large_txn(&mut engine, k, k, ts(60, 0), ts(60, 0), 100);
        check_txn_status::tests::must_success(
            &mut engine,
            k,
            ts(60, 0),

Review comment (bug):
```suggestion
            // The mvcc info should be collected committing secondary keys as it could be a bug.
            // Although the commit role is none, the primary key could be read from the lock.
```

Code after:
            // The primary key should not collect mvcc because it is an expected case.
            false,
        );
        check_commit_ts_expired_err(
            must_err(
                &mut engine,
                k2,
                ts(10, 0),
                ts(15, 0),
                Some(CommitRole::Secondary),
            ),
            k2,
            ts(10, 0),
            ts(15, 0),
            ts(20, 1),
            // The secondary key should not collect mvcc because it may be a bug.
            true,
        );
        check_commit_ts_expired_err(
            must_err(&mut engine, k2, ts(10, 0), ts(20, 0), None),
            k2,
            ts(10, 0),
            ts(20, 0),
            ts(20, 1),
            // The mvcc info should be collected committing secondary keys as it could be a bug.
            // Although the commit role is none, the primary key could be read from the lock.
            true,
        );
        must_succeed(&mut engine, k, ts(10, 0), ts(20, 1));

        must_prewrite_put_for_large_txn(&mut engine, k, v, k, ts(30, 0), 100, 0);
        check_txn_status::tests::must_success(
            &mut engine,
            k,
            ts(30, 0),
            ts(40, 0),
            ts(40, 0),
            true,
            false,
            false,
            uncommitted(100, ts(40, 1)),
        );
        must_succeed(&mut engine, k, ts(30, 0), ts(50, 0));

        // If the min_commit_ts of the pessimistic lock is greater than prewrite's, use
        // it.
        must_acquire_pessimistic_lock_for_large_txn(&mut engine, k, k, ts(60, 0), ts(60, 0), 100);
        check_txn_status::tests::must_success(
            &mut engine,
            k,
            ts(60, 0),