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/backend: rename Lock() to RLock() in ReadTx interface #10506

Merged
merged 1 commit into from
Mar 5, 2019

Conversation

jingyih
Copy link
Contributor

@jingyih jingyih commented Feb 27, 2019

For better code readability, renaming Lock() to RLock() in ReadTx interface.

This is my first attempt to address #10505. Personally I do not think we should wrap RLock() in a function named Lock(). But renaming the function does come with challenges. It is cause by the fact that ReadTx interface in embedded in BatchTx interface, and RLock() does not have a proper semantic under BatchTx interface.

Please let me know if this PR actually helps improve readability, or it adds more confusion.

FYI, I also added some comments to explain how the locks affect backend concurrency on reads and writes.

@jingyih
Copy link
Contributor Author

jingyih commented Feb 27, 2019

/cc @xiang90 @gyuho @jpbetz

@codecov-io
Copy link

codecov-io commented Feb 28, 2019

Codecov Report

Merging #10506 into master will increase coverage by 0.09%.
The diff coverage is 76.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10506      +/-   ##
==========================================
+ Coverage    71.4%   71.49%   +0.09%     
==========================================
  Files         393      393              
  Lines       36503    36511       +8     
==========================================
+ Hits        26064    26105      +41     
+ Misses       8604     8572      -32     
+ Partials     1835     1834       -1
Impacted Files Coverage Δ
mvcc/kvstore_txn.go 65.95% <100%> (ø) ⬆️
mvcc/kvstore.go 85.35% <100%> (ø) ⬆️
mvcc/watchable_store.go 83.5% <100%> (-0.71%) ⬇️
mvcc/backend/read_tx.go 84.31% <100%> (+0.64%) ⬆️
mvcc/backend/backend.go 74.15% <100%> (ø) ⬆️
mvcc/backend/batch_tx.go 57.3% <57.14%> (-0.84%) ⬇️
clientv3/concurrency/election.go 79.68% <0%> (-2.35%) ⬇️
etcdctl/ctlv3/command/printer_simple.go 72.48% <0%> (-1.35%) ⬇️
pkg/adt/interval_tree.go 82.28% <0%> (-1.21%) ⬇️
etcdserver/api/rafthttp/peer.go 78.77% <0%> (-1.12%) ⬇️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a943ad0...923e50e. Read the comment docs.

@jingyih jingyih force-pushed the improve_etcd_backend_readability branch from bf90ed8 to 923e50e Compare February 28, 2019 22:05
mvcc/backend/read_tx.go Outdated Show resolved Hide resolved
For better code readability, renaming Lock() to RLock() in ReadTx
interface.
@jingyih jingyih force-pushed the improve_etcd_backend_readability branch from 923e50e to 1c19f12 Compare March 5, 2019 21:53
@xiang90
Copy link
Contributor

xiang90 commented Mar 5, 2019

lgtm

@xiang90 xiang90 merged commit b08e6db into etcd-io:master Mar 5, 2019
@jingyih jingyih deleted the improve_etcd_backend_readability branch September 7, 2019 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants