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

fix(replica): add logs for io timeout in replica #186

Merged
merged 2 commits into from Feb 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 38 additions & 5 deletions rpc/server.go
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/openebs/jiva/types"
)

type operation func(*Message)
type Server struct {
wire *Wire
responses chan *Message
Expand Down Expand Up @@ -78,6 +79,37 @@ func (s *Server) Handle() error {
}
}

// timed is wrapper over various operations to varify whether
// those operations took more than the expected time to complete.
func timed(f operation, msg *Message) {
msgType := msg.Type
start := time.Now()
f(msg)
timeSinceStart := time.Since(start)
switch msgType {
case TypeRead:
if timeSinceStart > opReadTimeout {
logrus.Warningf("Read time: %vs greater than read timeout: %v at controller", timeSinceStart.Seconds(), opReadTimeout)
}
case TypeWrite:
if timeSinceStart > opWriteTimeout {
logrus.Warningf("Write time: %vs greater than write timeout: %v at controller", timeSinceStart.Seconds(), opWriteTimeout)
}
case TypeSync:
if timeSinceStart > opSyncTimeout {
logrus.Warningf("Sync time: %vs greater than sync timeout: %v at controller", timeSinceStart.Seconds(), opSyncTimeout)
}
case TypeUnmap:
if timeSinceStart > opUnmapTimeout {
logrus.Warningf("Unmap time: %vs greater than unmap timeout: %v at controller", timeSinceStart.Seconds(), opUnmapTimeout)
}
case TypePing:
if timeSinceStart > opPingTimeout {
logrus.Warningf("Ping time: %vs greater than ping timeout: %v at controller", timeSinceStart.Seconds(), opPingTimeout)
}
}
}

func (s *Server) readWrite(ret chan<- error) {
for {
inject.AddPingTimeout()
Expand All @@ -91,17 +123,18 @@ func (s *Server) readWrite(ret chan<- error) {
ret <- err
break
}

switch msg.Type {
case TypeRead:
s.handleRead(msg)
timed(s.handleRead, msg)
case TypeWrite:
s.handleWrite(msg)
timed(s.handleWrite, msg)
case TypePing:
s.handlePing(msg)
timed(s.handlePing, msg)
case TypeSync:
s.handleSync(msg)
timed(s.handleSync, msg)
case TypeUnmap:
s.handleUnmap(msg)
timed(s.handleUnmap, msg)
/*
case TypeUpdate:
go s.handleUpdate(msg)
Expand Down