Vnegi |
02-03-2022 07:08 AM |
CIFS: read block indefinitely for file
Our on production system we have mounted the Azure file share using the CIFS (using kubernetes).
For certain files, we see our program block on reading indefinitely. Our application stack is golang. Hence sharing the golang script.
A sample script to read the affected file 10 bytes at a time eventual hang
Code:
package main
import (
"fmt"
"io"
"os"
"time"
)
func main() {
handler, err := os.Open(os.Args[1])
if err != nil {
panic(err)
}
defer func() {
err := handler.Close()
fmt.Println("Error", err)
}()
var totalBytes int64
var totalCounter int64 = 0
for {
d := make([]byte, 10)
// bufio.NewReader(handler).Read
// 2147483647
// 3461194000
n, err := handler.Read(d)
if err != nil && err != io.EOF {
panic(err)
}
if err == io.EOF {
fmt.Println("EOF received")
break
}
totalBytes += int64(n)
if (n != 0) && (totalCounter%10000000) == 0 {
kb := totalBytes / 1024
mb := kb / 1024
gb := mb / 1024
fmt.Println(time.Now())
fmt.Printf("%d %d %d %d %d\n", totalCounter, totalBytes, kb, mb, gb)
totalCounter = 0
}
totalCounter++
if (totalBytes / 1024) >= 3461180 {
fmt.Printf("%s\n", d)
}
}
}
We have are read blocked on certain files indefinitely as if the EOF was never seen.
Here the stack trace obtained after SIGSEGV was triggered
Quote:
SIGSEGV: segmentation violation
PC=0x45d1e1 m=0 sigcode=0
goroutine 0 [idle]:
runtime.futex()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/sys_linux_amd64.s:519 +0x21
runtime.futexsleep(0xc000022000, 0xdbbbfe30, 0x421831)
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/os_linux.go:44 +0x36
runtime.notesleep(0x53ccb0)
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/lock_futex.go:160 +0x87
runtime.mPark()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/proc.go:1441 +0x2a
runtime.stopm()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/proc.go:2408 +0x78
runtime.findrunnable()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/proc.go:2984 +0x865
runtime.schedule()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/proc.go:3367 +0x239
runtime.park_m(0xc000001380)
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/proc.go:3516 +0x14d
runtime.mcall()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/asm_amd64.s:307 +0x43
goroutine 1 [syscall, 40 minutes]:
syscall.Syscall(0x0, 0x3, 0xc000256430, 0xa)
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/asm_linux_amd64.s:20 +0x5
syscall.read(0xc0000b6120, {0xc000256430, 0x7f6604197ce0, 0x5})
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/zsyscall_linux_amd64.go:687 +0x4d
syscall.Read(...)
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/syscall_unix.go:189
internal/poll.ignoringEINTRIO(...)
/usr/local/Cellar/go/1.17.2/libexec/src/internal/poll/fd_unix.go:582
internal/poll.(*FD).Read(0xc0000b6120, {0xc000256430, 0xa, 0xa})
/usr/local/Cellar/go/1.17.2/libexec/src/internal/poll/fd_unix.go:163 +0x285
os.(*File).read(...)
/usr/local/Cellar/go/1.17.2/libexec/src/os/file_posix.go:32
os.(*File).Read(0xc0000b4018, {0xc000256430, 0xa, 0xa})
/usr/local/Cellar/go/1.17.2/libexec/src/os/file.go:119 +0x5e
main.main()
/Users/admin/Documents/goProject/src/github.com/ringsq/detech-eof.go:22 +0xb6
|
|