Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
c1057693
Commit
c1057693
authored
Sep 01, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2bc466f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
10 deletions
+74
-10
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+58
-2
go/xcommon/tracing/tracing.go
go/xcommon/tracing/tracing.go
+15
-7
go/xcommon/xtesting/xtesting.go
go/xcommon/xtesting/xtesting.go
+1
-1
No files found.
go/neo/server/cluster_test.go
View file @
c1057693
...
@@ -27,10 +27,10 @@ import (
...
@@ -27,10 +27,10 @@ import (
"bytes"
"bytes"
"context"
"context"
"crypto/sha1"
"crypto/sha1"
//
"io"
"io"
"math"
"math"
"net"
"net"
//
"reflect"
"reflect"
"testing"
"testing"
"unsafe"
"unsafe"
...
@@ -473,6 +473,62 @@ func TestMasterStorage(t *testing.T) {
...
@@ -473,6 +473,62 @@ func TestMasterStorage(t *testing.T) {
println
(
"444"
)
println
(
"444"
)
// C loads every other {<,=}serial:oid - established link is reused
ziter
:=
zstor
.
Iterate
(
0
,
zodb
.
TidMax
)
// XXX hack: disable tracing early so that C.Load() calls do not deadlock
// TODO refactor cluster creation into func
// TODO move client all loading tests into separate test where tracing will be off
pg
.
Done
()
for
{
_
,
dataIter
,
err
:=
ziter
.
NextTxn
()
if
err
==
io
.
EOF
{
break
}
if
err
!=
nil
{
t
.
Fatalf
(
"ziter.NextTxn: %v"
,
err
)
}
for
{
datai
,
err
:=
dataIter
.
NextData
()
if
err
==
io
.
EOF
{
break
}
if
err
!=
nil
{
t
.
Fatalf
(
"ziter.NextData: %v"
,
err
)
}
for
_
,
tidBefore
:=
range
[]
bool
{
false
,
true
}
{
xid
:=
zodb
.
Xid
{
Oid
:
datai
.
Oid
}
// {=,<}tid:oid
xid
.
Tid
=
datai
.
Tid
xid
.
TidBefore
=
tidBefore
if
tidBefore
{
xid
.
Tid
++
}
println
(
"555"
)
data
,
tid
,
err
:=
C
.
Load
(
bg
,
xid
)
println
(
"777"
)
if
datai
.
Data
!=
nil
{
if
!
(
bytes
.
Equal
(
data
,
datai
.
Data
)
&&
tid
==
datai
.
Tid
&&
err
==
nil
)
{
t
.
Fatalf
(
"load: %v:
\n
have: %v %v %q
\n
want: %v nil %q"
,
xid
,
tid
,
err
,
data
,
datai
.
Tid
,
datai
.
Data
)
}
}
else
{
// deleted
errWant
:=
&
zodb
.
ErrXidMissing
{
xid
}
if
!
(
data
==
nil
&&
tid
==
0
&&
reflect
.
DeepEqual
(
err
,
errWant
))
{
t
.
Fatalf
(
"load: %v:
\n
have: %v, %#v, %#v
\n
want: %v, %#v, %#v"
,
xid
,
tid
,
err
,
data
,
zodb
.
Tid
(
0
),
errWant
,
[]
byte
(
nil
))
}
}
}
}
}
...
...
go/xcommon/tracing/tracing.go
View file @
c1057693
...
@@ -200,13 +200,15 @@ package tracing
...
@@ -200,13 +200,15 @@ package tracing
import
(
import
(
"sync"
"sync"
"sync/atomic"
"sync/atomic"
"fmt"
)
)
// big tracing lock
// big tracing lock
var
traceMu
sync
.
Mutex
var
traceMu
sync
.
Mutex
var
traceLocked
int32
// for cheap protective checks whether Lock is held
var
traceLocked
int32
// for cheap protective checks whether Lock is held
// Lock serializes modification access to tracepoints
// Lock serializes modification access to tracepoints
.
//
//
// Under Lock it is safe to attach/detach probes to/from tracepoints:
// Under Lock it is safe to attach/detach probes to/from tracepoints:
// - no other goroutine is attaching or detaching probes from tracepoints,
// - no other goroutine is attaching or detaching probes from tracepoints,
...
@@ -249,13 +251,15 @@ type Probe struct {
...
@@ -249,13 +251,15 @@ type Probe struct {
// probefunc func(some arguments)
// probefunc func(some arguments)
}
}
// Next returns next probe attached to the same tracepoint
// Next returns next probe attached to the same tracepoint.
//
// It is safe to iterate Next under any conditions.
// It is safe to iterate Next under any conditions.
func
(
p
*
Probe
)
Next
()
*
Probe
{
func
(
p
*
Probe
)
Next
()
*
Probe
{
return
p
.
next
return
p
.
next
}
}
// AttachProbe attaches newly created Probe to the end of a probe list
// AttachProbe attaches newly created Probe to the end of a probe list.
//
// If group is non-nil the probe is also added to the group.
// If group is non-nil the probe is also added to the group.
// Must be called under Lock.
// Must be called under Lock.
// Probe must be newly created.
// Probe must be newly created.
...
@@ -283,7 +287,8 @@ func AttachProbe(pg *ProbeGroup, listp **Probe, probe *Probe) {
...
@@ -283,7 +287,8 @@ func AttachProbe(pg *ProbeGroup, listp **Probe, probe *Probe) {
}
}
}
}
// Detach detaches probe from a tracepoint
// Detach detaches probe from a tracepoint.
//
// Must be called under Lock
// Must be called under Lock
func
(
p
*
Probe
)
Detach
()
{
func
(
p
*
Probe
)
Detach
()
{
verifyLocked
()
verifyLocked
()
...
@@ -313,19 +318,21 @@ func (p *Probe) Detach() {
...
@@ -313,19 +318,21 @@ func (p *Probe) Detach() {
p
.
prev
=
p
p
.
prev
=
p
}
}
// ProbeGroup is a group of probes attached to tracepoints
// ProbeGroup is a group of probes attached to tracepoints
.
type
ProbeGroup
struct
{
type
ProbeGroup
struct
{
probev
[]
*
Probe
probev
[]
*
Probe
}
}
// Add adds a probe to the group
// Add adds a probe to the group.
//
// Must be called under Lock
// Must be called under Lock
func
(
pg
*
ProbeGroup
)
Add
(
p
*
Probe
)
{
func
(
pg
*
ProbeGroup
)
Add
(
p
*
Probe
)
{
verifyLocked
()
verifyLocked
()
pg
.
probev
=
append
(
pg
.
probev
,
p
)
pg
.
probev
=
append
(
pg
.
probev
,
p
)
}
}
// Done detaches all probes registered to the group
// Done detaches all probes registered to the group.
//
// Must be called under normal conditions, not under Lock
// Must be called under normal conditions, not under Lock
func
(
pg
*
ProbeGroup
)
Done
()
{
func
(
pg
*
ProbeGroup
)
Done
()
{
verifyUnlocked
()
verifyUnlocked
()
...
@@ -333,6 +340,7 @@ func (pg *ProbeGroup) Done() {
...
@@ -333,6 +340,7 @@ func (pg *ProbeGroup) Done() {
defer
Unlock
()
defer
Unlock
()
for
_
,
p
:=
range
pg
.
probev
{
for
_
,
p
:=
range
pg
.
probev
{
fmt
.
Printf
(
"detaching %#v
\n
"
,
p
)
p
.
Detach
()
p
.
Detach
()
}
}
pg
.
probev
=
nil
pg
.
probev
=
nil
...
...
go/xcommon/xtesting/xtesting.go
View file @
c1057693
...
@@ -59,7 +59,7 @@ func NewSyncTracer() *SyncTracer {
...
@@ -59,7 +59,7 @@ func NewSyncTracer() *SyncTracer {
// Trace1 sends message with 1 tracing event to a consumer and waits for ack
// Trace1 sends message with 1 tracing event to a consumer and waits for ack
func
(
st
*
SyncTracer
)
Trace1
(
event
interface
{})
{
func
(
st
*
SyncTracer
)
Trace1
(
event
interface
{})
{
ack
:=
make
(
chan
struct
{})
ack
:=
make
(
chan
struct
{})
//
fmt.Printf("trace: send: %T %v\n", event, event)
fmt
.
Printf
(
"trace: send: %T %v
\n
"
,
event
,
event
)
st
.
tracech
<-
&
SyncTraceMsg
{
event
,
ack
}
st
.
tracech
<-
&
SyncTraceMsg
{
event
,
ack
}
<-
ack
<-
ack
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment