fix #274. open a new fd for replay
Since we have to seek to the right location of the file, we cannot use the same fd or dup it. File descriptors share the same file location.pull/290/head
parent
b931784b3f
commit
c42e613afe
|
@ -12,7 +12,6 @@ import (
|
|||
"protocol"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type log struct {
|
||||
|
@ -111,7 +110,6 @@ func (self *log) recover() error {
|
|||
|
||||
self.state.RequestsSinceLastBookmark = 0
|
||||
self.state.RequestsSinceLastIndex = 0
|
||||
self.state.setFileOffset(self.state.FileOffset)
|
||||
|
||||
logger.Debug("Recovering from previous state from file offset: %d", self.state.FileOffset)
|
||||
|
||||
|
@ -227,11 +225,7 @@ func (self *log) appendRequest(request *protocol.Request, shardId uint32) (uint3
|
|||
}
|
||||
|
||||
func (self *log) dupLogFile() (*os.File, error) {
|
||||
fd, err := syscall.Dup(int(self.file.Fd()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return os.NewFile(uintptr(fd), self.file.Name()), nil
|
||||
return os.OpenFile(self.file.Name(), os.O_RDONLY, 0)
|
||||
}
|
||||
|
||||
// replay requests starting at the given requestNumber and for the
|
||||
|
|
Loading…
Reference in New Issue