Commit 40410799 authored by Kirill Smelkov's avatar Kirill Smelkov

X recovery: on startup S PENDING -> RUNNING

parent ca0ffd62
...@@ -211,14 +211,14 @@ func TestMasterStorage(t *testing.T) { ...@@ -211,14 +211,14 @@ func TestMasterStorage(t *testing.T) {
Mhost := xnet.NetTrace(net.Host("m"), tracer) Mhost := xnet.NetTrace(net.Host("m"), tracer)
Shost := xnet.NetTrace(net.Host("s"), tracer) Shost := xnet.NetTrace(net.Host("s"), tracer)
wg := &xsync.WorkGroup{} gwg := &xsync.WorkGroup{}
// start master // start master
Mclock := &vclock{} Mclock := &vclock{}
M := NewMaster("abc1", ":1", Mhost) M := NewMaster("abc1", ":1", Mhost)
M.monotime = Mclock.monotime M.monotime = Mclock.monotime
Mctx, Mcancel := context.WithCancel(context.Background()) Mctx, Mcancel := context.WithCancel(context.Background())
wg.Gox(func() { gwg.Gox(func() {
err := M.Run(Mctx) err := M.Run(Mctx)
fmt.Println("M err: ", err) fmt.Println("M err: ", err)
_ = err // XXX _ = err // XXX
...@@ -235,7 +235,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -235,7 +235,7 @@ func TestMasterStorage(t *testing.T) {
zstor := xfs1stor("../../zodb/storage/fs1/testdata/1.fs") zstor := xfs1stor("../../zodb/storage/fs1/testdata/1.fs")
S := NewStorage("abc1", "m:1", ":1", Shost, zstor) S := NewStorage("abc1", "m:1", ":1", Shost, zstor)
Sctx, Scancel := context.WithCancel(context.Background()) Sctx, Scancel := context.WithCancel(context.Background())
wg.Gox(func() { gwg.Gox(func() {
err := S.Run(Sctx) err := S.Run(Sctx)
fmt.Println("S err: ", err) fmt.Println("S err: ", err)
_ = err // XXX _ = err // XXX
...@@ -285,8 +285,14 @@ func TestMasterStorage(t *testing.T) { ...@@ -285,8 +285,14 @@ func TestMasterStorage(t *testing.T) {
tc.Expect(masterStartReady(M, true)) tc.Expect(masterStartReady(M, true))
// M <- start cmd // M <- start cmd
err := M.Start() wg := &xsync.WorkGroup{}
exc.Raiseif(err) wg.Gox(func() {
err := M.Start()
exc.Raiseif(err)
})
tc.Expect(node(M.nodeTab, "s:1", neo.STORAGE, 1, neo.RUNNING, 0.01))
xwait(wg)
// XXX M.partTab <- S1 // XXX M.partTab <- S1
// XXX M can start -> writes parttab to S and goes to verification // XXX M can start -> writes parttab to S and goes to verification
...@@ -328,7 +334,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -328,7 +334,7 @@ func TestMasterStorage(t *testing.T) {
// TODO test M.recovery starting back from verification/service // TODO test M.recovery starting back from verification/service
// (M needs to resend to all storages recovery messages just from start) // (M needs to resend to all storages recovery messages just from start)
xwait(wg) xwait(gwg)
Mcancel() // XXX temp Mcancel() // XXX temp
Scancel() // XXX temp Scancel() // XXX temp
} }
......
...@@ -451,6 +451,19 @@ loop2: ...@@ -451,6 +451,19 @@ loop2:
} }
} }
if err != nil {
return err
}
// recovery successful - we are starting
// S PENDING -> RUNNING
for _, stor := range m.nodeTab.StorageList() {
if stor.State == neo.PENDING {
m.nodeTab.SetNodeState(stor, neo.RUNNING)
}
}
// if we are starting for new cluster - create partition table // if we are starting for new cluster - create partition table
if err != nil && m.partTab.PTid == 0 { if err != nil && m.partTab.PTid == 0 {
// XXX -> m.nodeTab.StorageList(State > DOWN) // XXX -> m.nodeTab.StorageList(State > DOWN)
...@@ -461,9 +474,10 @@ loop2: ...@@ -461,9 +474,10 @@ loop2:
} }
} }
m.partTab = neo.MakePartTab(1 /* XXX hardcoded */, storv) m.partTab = neo.MakePartTab(1 /* XXX hardcoded */, storv)
m.partTab.PTid = 1
} }
return err return nil
} }
// storCtlRecovery drives a storage node during cluster recovering state // storCtlRecovery drives a storage node during cluster recovering state
......
...@@ -58,6 +58,7 @@ func NewSyncTracer() *SyncTracer { ...@@ -58,6 +58,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)
st.tracech <- &SyncTraceMsg{event, ack} st.tracech <- &SyncTraceMsg{event, ack}
<-ack <-ack
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment