Skip to content

Conversation

@disksing
Copy link
Collaborator

Signed-off-by: disksing i@disksing.com

Signed-off-by: disksing <i@disksing.com>
@disksing
Copy link
Collaborator Author

Please take a look if you have spare time. @sunxiaoguang

@sunxiaoguang
Copy link
Member

Please take a look if you have spare time. @sunxiaoguang

Thanks, it's a good start for me to have better knowledge of it.


// valueDecoder decodes a mvcc value if iter key is expectKey.
func (dec *valueDecoder) Decode(iter *Iterator) (bool, error) {
if iter.Error() != nil || !iter.Valid() {
Copy link
Member

Choose a reason for hiding this comment

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

It seems the validation has already been checked outside of this function except

ok, err = dec1.Decode(iter)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copied from tidb directly. /cc @tiancaiamao Do you have any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a valid field here

If iter.valid is false, the Decode function should return as soon as possible. @rleungx

The code is copied, I recommend not to modify it in this PR, if any bug is found, use a separate one to fix it.
b.t.w, tikv/client will be moved from tidb to this repo later? @disksing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. That's exactly I'm working on.

Signed-off-by: disksing <i@disksing.com>
// GetAllRegions gets all the regions in the cluster.
func (c *Cluster) GetAllRegions() []*Region {
regions := make([]*Region, 0, len(c.regions))
for _, region := range c.regions {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need RLock here?

defer c.RUnlock()

r := c.regions[regionID]
if r == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe using if r, ok := c.regions[regionID]; !ok is better?


func newRegion(regionID uint64, storeIDs, peerIDs []uint64, leaderPeerID uint64) *Region {
if len(storeIDs) != len(peerIDs) {
panic("len(storeIDs) != len(peerIds)")
Copy link
Member

Choose a reason for hiding this comment

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

peerIDs. BTW, is this a good panic message?

@@ -0,0 +1,51 @@
// Copyright 2016 PingCAP, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

should change all licenses to 2019?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No need to. The file is copied from tidb.

Copy link
Member

@sunxiaoguang sunxiaoguang Feb 22, 2019

Choose a reason for hiding this comment

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

Sadly, I have done the changes already in mock-tikv...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it does not matter to change it or not to :)

@siddontang
Copy link
Contributor

@disksing

Maybe is it better to port and merge at first, then do the improvement later?

Signed-off-by: disksing <i@disksing.com>
@disksing disksing merged commit af8a9cd into tikv:master Mar 8, 2019
@disksing disksing deleted the rawkv-test branch March 8, 2019 08:21
daimashusheng pushed a commit to daimashusheng/client-go that referenced this pull request Sep 2, 2021
* add mockstore and rawkv tests

Signed-off-by: disksing <i@disksing.com>
sunxiaoguang pushed a commit to sunxiaoguang/client-go that referenced this pull request Jul 18, 2022
you06-pingcap pushed a commit to you06/client-go that referenced this pull request Dec 2, 2025
* implement resolve lock

Signed-off-by: you06 <you1474600@gmail.com>

* remote comment code

Signed-off-by: you06 <you1474600@gmail.com>

* add license

Signed-off-by: you06 <you1474600@gmail.com>

* add test for gc shared lock

Signed-off-by: you06 <you1474600@gmail.com>

* address comment

Signed-off-by: you06 <you1474600@gmail.com>

---------

Signed-off-by: you06 <you1474600@gmail.com>
cfzjywxk pushed a commit that referenced this pull request Dec 3, 2025
* *: add basic support for shared lock

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* update kvproto

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* make some minor updates

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* add basic tests for LockKeys

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* bump kvproto

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* shared lock: support rollback/resolve, add tests (#2)

* implement resolve lock

Signed-off-by: you06 <you1474600@gmail.com>

* remote comment code

Signed-off-by: you06 <you1474600@gmail.com>

* add license

Signed-off-by: you06 <you1474600@gmail.com>

* add test for gc shared lock

Signed-off-by: you06 <you1474600@gmail.com>

* address comment

Signed-off-by: you06 <you1474600@gmail.com>

---------

Signed-off-by: you06 <you1474600@gmail.com>

* fix test (#3)

Signed-off-by: you06 <you1474600@gmail.com>

* txnkv: prevent shared locks from being resolved by accidently

Signed-off-by: zyguan <zhongyangguan@gmail.com>

---------

Signed-off-by: zyguan <zhongyangguan@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Co-authored-by: you06 <you1474600@gmail.com>
you06-pingcap pushed a commit to you06/client-go that referenced this pull request Dec 22, 2025
* *: add basic support for shared lock

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* update kvproto

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* make some minor updates

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* add basic tests for LockKeys

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* bump kvproto

Signed-off-by: zyguan <zhongyangguan@gmail.com>

* shared lock: support rollback/resolve, add tests (tikv#2)

* implement resolve lock

Signed-off-by: you06 <you1474600@gmail.com>

* remote comment code

Signed-off-by: you06 <you1474600@gmail.com>

* add license

Signed-off-by: you06 <you1474600@gmail.com>

* add test for gc shared lock

Signed-off-by: you06 <you1474600@gmail.com>

* address comment

Signed-off-by: you06 <you1474600@gmail.com>

---------

Signed-off-by: you06 <you1474600@gmail.com>

* fix test (tikv#3)

Signed-off-by: you06 <you1474600@gmail.com>

* txnkv: prevent shared locks from being resolved by accidently

Signed-off-by: zyguan <zhongyangguan@gmail.com>

---------

Signed-off-by: zyguan <zhongyangguan@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Co-authored-by: you06 <you1474600@gmail.com>
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