From c42e613afea1ec73b9627017a82fcbdef65d4f98 Mon Sep 17 00:00:00 2001 From: John Shahid Date: Wed, 26 Feb 2014 20:42:25 -0500 Subject: [PATCH] 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. --- src/wal/log.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/wal/log.go b/src/wal/log.go index c34a0fcf41..83b9cc924f 100644 --- a/src/wal/log.go +++ b/src/wal/log.go @@ -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