Skip to content
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

mvcc/reader: ignore Lock when lock's type is Lock #3011

Merged
merged 6 commits into from
May 7, 2018

Conversation

AndreMouche
Copy link
Member

@AndreMouche AndreMouche commented May 2, 2018

When we adding an index, the row will be locked with 'lock' type, which means it's not allowed to write.

But the value is not changed. We can continue to read the row without the need to return an lock error when we meet the lock.
@disksing @zhangjinpeng1987 @coocood PTAL

@coocood
Copy link
Contributor

coocood commented May 2, 2018

@AndreMouche
I think we should not modify the read ts.
It should just ignore the lock and continue to find the version <= read ts

@disksing
Copy link
Contributor

disksing commented May 2, 2018

LGTM.

@zhangjinpeng87
Copy link
Member

zhangjinpeng87 commented May 3, 2018

fn check_lock(&mut self, key: &Key, mut ts: u64) -> Result<Option<u64>> {
        if let Some(lock) = self.load_lock(key)? {
            if lock.ts <= ts {
                if ts == u64::MAX && key.raw()? == lock.primary {
                    // when ts==u64::MAX(which means to get latest committed version for
                    // primary key),and current key is the primary key, returns the latest
                    // commit version’s value
                    ts = lock.ts - 1;
                } else if lock.lock_type != LockType::Lock {
                    // There is a pending lock. Client should wait or clean it.
                    return Err(Error::KeyIsLocked {
                        key: key.raw()?,
                        primary: lock.primary,
                        ts: lock.ts,
                        ttl: lock.ttl,
                    });
               }
            }
        }
        Ok(Some(ts))
    } 

@AndreMouche AndreMouche changed the title mvcc/reader: return the latest commit version when lock's type is Lock mvcc/reader: ignore Lock when lock's type is Lock May 3, 2018
@coocood
Copy link
Contributor

coocood commented May 4, 2018

LGTM

@AndreMouche
Copy link
Member Author

@zhangjinpeng1987 @disksing PTAL

@AndreMouche
Copy link
Member Author

/run-integration-tests

@disksing
Copy link
Contributor

disksing commented May 4, 2018

LGTM.

@siddontang
Copy link
Contributor

Please add a description for it.

@zhangjinpeng87
Copy link
Member

LGTM

Copy link
Contributor

@disksing disksing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndreMouche AndreMouche merged commit b605387 into tikv:master May 7, 2018
BusyJay pushed a commit to BusyJay/tikv that referenced this pull request May 10, 2018
BusyJay added a commit that referenced this pull request May 10, 2018
* Open nightly feature gate for crossbeam-channel. (#2995)

* mvcc/reader: ignore Lock when lock's type is Lock (#3011)

* coprocessor/endpoint: show client's ip in slow log (#3002)

* Show wait time and reverse scan in slow log (#3017)

* Use AtomicU64 instead RwLock for tracking snapshot size. (#3020)

* bump 2.0.1-beta
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants