MCPcopy
hub / github.com/etcd-io/bbolt / executeLongRunningRead

Function executeLongRunningRead

concurrent_test.go:930–956  ·  view source on GitHub ↗
(t *testing.T, name string, db *bolt.DB, bucket []byte, key []byte, readInterval duration, stopCh chan struct{})

Source from the content-addressed store, hash-verified

928}
929
930func executeLongRunningRead(t *testing.T, name string, db *bolt.DB, bucket []byte, key []byte, readInterval duration, stopCh chan struct{}) error {
931 err := db.View(func(tx *bolt.Tx) error {
932 b := tx.Bucket(bucket)
933
934 initialVal := b.Get(key)
935
936 for {
937 select {
938 case <-stopCh:
939 t.Logf("%q finished.", name)
940 return nil
941 default:
942 }
943
944 time.Sleep(randomDurationInRange(readInterval.min, readInterval.max))
945 val := b.Get(key)
946
947 if !bytes.Equal(initialVal, val) {
948 dirtyReadErr := fmt.Errorf("read different values for the same key (%q), value1: %q, value2: %q",
949 string(key), formatBytes(initialVal), formatBytes(val))
950 return dirtyReadErr
951 }
952 }
953 })
954
955 return err
956}

Callers 1

Calls 6

randomDurationInRangeFunction · 0.85
ViewMethod · 0.80
formatBytesFunction · 0.70
ErrorfMethod · 0.65
BucketMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected