mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #16312 from serathius/rlock
server: Remove Lock/Unlock from ReadTx
This commit is contained in:
commit
145cae36ef
@ -45,6 +45,8 @@ type Bucket interface {
|
||||
|
||||
type BatchTx interface {
|
||||
ReadTx
|
||||
Lock()
|
||||
Unlock()
|
||||
UnsafeCreateBucket(bucket Bucket)
|
||||
UnsafeDeleteBucket(bucket Bucket)
|
||||
UnsafePut(bucket Bucket, key []byte, value []byte)
|
||||
|
@ -26,13 +26,6 @@ import (
|
||||
// is known to never overwrite any key so range is safe.
|
||||
|
||||
type ReadTx interface {
|
||||
// Lock and Unlock should only be used in the following three cases:
|
||||
// 1. When committing a transaction. Because it will reset the read tx, including the buffer;
|
||||
// 2. When writing the pending data back to read buf, because obviously no reading is allowed when writing the read buffer;
|
||||
// 3. When performing defragmentation, because again it will reset the read tx, including the read buffer.
|
||||
Lock()
|
||||
Unlock()
|
||||
// RLock and RUnlock should be used for all other cases.
|
||||
RLock()
|
||||
RUnlock()
|
||||
|
||||
|
@ -54,8 +54,8 @@ func TestMustUnsafeSaveConfStateToBackend(t *testing.T) {
|
||||
|
||||
t.Run("missing", func(t *testing.T) {
|
||||
tx := be.ReadTx()
|
||||
tx.Lock()
|
||||
defer tx.Unlock()
|
||||
tx.RLock()
|
||||
defer tx.RUnlock()
|
||||
assert.Nil(t, UnsafeConfStateFromBackend(lg, tx))
|
||||
})
|
||||
|
||||
@ -71,8 +71,8 @@ func TestMustUnsafeSaveConfStateToBackend(t *testing.T) {
|
||||
|
||||
t.Run("read", func(t *testing.T) {
|
||||
tx := be.ReadTx()
|
||||
tx.Lock()
|
||||
defer tx.Unlock()
|
||||
tx.RLock()
|
||||
defer tx.RUnlock()
|
||||
assert.Equal(t, confState, *UnsafeConfStateFromBackend(lg, tx))
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user