nkanaev / yarr

yet another rss reader
MIT License
3.02k stars 225 forks source link

crash immediately after starting #101

Closed minioin closed 2 years ago

minioin commented 2 years ago

Crash happens only when I load the web interface.

2022/06/11 18:47:08 worker.go:105: Refreshing feeds
fatal error: concurrent map read and map write

goroutine 195 [running]:
runtime.throw({0x964509?, 0xc0007277c8?})
    /opt/hostedtoolcache/go/1.18.1/x64/src/runtime/panic.go:992 +0x71 fp=0xc000727770 sp=0xc000727740 pc=0x442bb1
runtime.mapaccess1_faststr(0x6f0000006e?, 0x94fecf?, {0xc0001188d0, 0x8})
    /opt/hostedtoolcache/go/1.18.1/x64/src/runtime/map_faststr.go:22 +0x3a5 fp=0xc0007277d8 sp=0xc000727770 pc=0x421585
github.com/nkanaev/yarr/src/server.(*Server).handleFeedIcon(0xc000198600, 0xc000489100)
    /home/runner/work/yarr/yarr/src/server/routes.go:162 +0xaf fp=0xc000727970 sp=0xc0007277d8 pc=0x7e278f
github.com/nkanaev/yarr/src/server.(*Server).handleFeedIcon-fm(0x91ea20?)
    <autogenerated>:1 +0x2c fp=0xc000727990 sp=0xc000727970 pc=0x7e59ec
github.com/nkanaev/yarr/src/server/router.(*Context).Next(...)
    /home/runner/work/yarr/yarr/src/server/router/context.go:24
quoing commented 2 years ago

Same issue with concurent map writes.. happening time to time..

2022-06-21 08:56:00 | fatal error: concurrent map writes
-- | --
  |   | 2022-06-21 08:56:00 | goroutine 41250 [running]:
  |   | 2022-06-21 08:56:00 | runtime.throw(0x9d2747, 0x15)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/runtime/panic.go:1117 +0x72 fp=0xc0006cd838 sp=0xc0006cd808 pc=0x43deb2
  |   | 2022-06-21 08:56:00 | runtime.mapassign_faststr(0x94e720, 0xc00007dd40, 0xc0005500e9, 0x7, 0xc)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/runtime/map_faststr.go:211 +0x3f1 fp=0xc0006cd8a0 sp=0xc0006cd838 pc=0x41bff1
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server.(*Server).handleFeedIcon(0xc000186600, 0xc0004dc9c0)
  |   | 2022-06-21 08:56:00 | /src/src/server/routes.go:180 +0x7f1 fp=0xc0006cda48 sp=0xc0006cd8a0 pc=0x81e151
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server.(*Server).handleFeedIcon-fm(0xc0004dc9c0)
  |   | 2022-06-21 08:56:00 | /src/src/server/routes.go:154 +0x3d fp=0xc0006cda68 sp=0xc0006cda48 pc=0x8219bd
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Context).Next(...)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/context.go:24
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/gzip.Middleware(0xc0004dc9c0)
  |   | 2022-06-21 08:56:00 | /src/src/server/gzip/middleware.go:42 +0x2ab fp=0xc0006cdaf0 sp=0xc0006cda68 pc=0x7dcdcb
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Context).Next(...)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/context.go:24
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Router).ServeHTTP(0xc000022ac0, 0xab3cd0, 0xc0003c6000, 0xc00034e200)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/router.go:81 +0x219 fp=0xc0006cdb70 sp=0xc0006cdaf0 pc=0x7db7b9
  |   | 2022-06-21 08:56:00 | net/http.serverHandler.ServeHTTP(0xc0001fe0e0, 0xab3cd0, 0xc0003c6000, 0xc00034e200)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:2887 +0xa3 fp=0xc0006cdba0 sp=0xc0006cdb70 pc=0x75e903
  |   | 2022-06-21 08:56:00 | net/http.(*conn).serve(0xc0002a4140, 0xab4880, 0xc0002d00c0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:1952 +0x8cd fp=0xc0006cdfc8 sp=0xc0006cdba0 pc=0x759d2d
  |   | 2022-06-21 08:56:00 | runtime.goexit()
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc0006cdfd0 sp=0xc0006cdfc8 pc=0x473981
  |   | 2022-06-21 08:56:00 | created by net/http.(*Server).Serve
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:3013 +0x39b
  |   | 2022-06-21 08:56:00 | goroutine 1 [IO wait]:
  |   | 2022-06-21 08:56:00 | internal/poll.runtime_pollWait(0x7f357628ebd8, 0x72, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/runtime/netpoll.go:222 +0x55
  |   | 2022-06-21 08:56:00 | internal/poll.(*pollDesc).wait(0xc000186918, 0x72, 0x0, 0x0, 0x9c87d5)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
  |   | 2022-06-21 08:56:00 | internal/poll.(*pollDesc).waitRead(...)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
  |   | 2022-06-21 08:56:00 | internal/poll.(*FD).Accept(0xc000186900, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_unix.go:401 +0x212
  |   | 2022-06-21 08:56:00 | net.(*netFD).accept(0xc000186900, 0x7a5505bc83eb8b2f, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/fd_unix.go:172 +0x45
  |   | 2022-06-21 08:56:00 | net.(*TCPListener).accept(0xc00000e288, 0x62b16b80, 0xc000221ac0, 0x4dfb86)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/tcpsock_posix.go:139 +0x32
  |   | 2022-06-21 08:56:00 | net.(*TCPListener).Accept(0xc00000e288, 0xc000221b10, 0x18, 0xc000000180, 0x75edfb)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/tcpsock.go:261 +0x65
  |   | 2022-06-21 08:56:00 | net/http.(*Server).Serve(0xc0001fe0e0, 0xab3ac0, 0xc00000e288, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:2981 +0x285
  |   | 2022-06-21 08:56:00 | net/http.(*Server).ListenAndServe(0xc0001fe0e0, 0xc0001fe0e0, 0xc000022ac0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:2910 +0xba
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server.(*Server).Start(0xc000186600)
  |   | 2022-06-21 08:56:00 | /src/src/server/server.go:59 +0x156
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/platform.Start(...)
  |   | 2022-06-21 08:56:00 | /src/src/platform/guiless.go:10
  |   | 2022-06-21 08:56:00 | main.main()
  |   | 2022-06-21 08:56:00 | /src/src/main.go:139 +0xff9
  |   | 2022-06-21 08:56:00 | goroutine 6 [select, 684 minutes]:
  |   | 2022-06-21 08:56:00 | database/sql.(*DB).connectionOpener(0xc00007f6c0, 0xab47d8, 0xc000022900)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/database/sql/sql.go:1133 +0xb5
  |   | 2022-06-21 08:56:00 | created by database/sql.OpenDB
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/database/sql/sql.go:740 +0x12a
  |   | 2022-06-21 08:56:00 | goroutine 9 [chan receive, 684 minutes]:
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/worker.(*Worker).StartFeedCleaner.func1(0xc0000205a0, 0xc00007dd10)
  |   | 2022-06-21 08:56:00 | /src/src/worker/worker.go:36 +0x37
  |   | 2022-06-21 08:56:00 | created by github.com/nkanaev/yarr/src/worker.(*Worker).StartFeedCleaner
  |   | 2022-06-21 08:56:00 | /src/src/worker/worker.go:34 +0x85
  |   | 2022-06-21 08:56:00 | goroutine 10 [select, 5 minutes]:
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/worker.(*Worker).SetRefreshRate.func1(0xc00007dd10, 0xc00002aa80, 0xc00007a120, 0xa)
  |   | 2022-06-21 08:56:00 | /src/src/worker/worker.go:78 +0x157
  |   | 2022-06-21 08:56:00 | created by github.com/nkanaev/yarr/src/worker.(*Worker).SetRefreshRate
  |   | 2022-06-21 08:56:00 | /src/src/worker/worker.go:75 +0xeb
  |   | 2022-06-21 08:56:00 | goroutine 691 [runnable]:
  |   | 2022-06-21 08:56:00 | net/textproto.MIMEHeader.Set(...)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/textproto/header.go:22
  |   | 2022-06-21 08:56:00 | net/http.Header.Set(...)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/header.go:37
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server.(*Server).handleFeedIcon(0xc000186600, 0xc00040c0c0)
  |   | 2022-06-21 08:56:00 | /src/src/server/routes.go:190 +0x2f5
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Context).Next(...)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/context.go:24
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/gzip.Middleware(0xc00040c0c0)
  |   | 2022-06-21 08:56:00 | /src/src/server/gzip/middleware.go:42 +0x2ab
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Context).Next(...)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/context.go:24
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Router).ServeHTTP(0xc000022ac0, 0xab3cd0, 0xc0002e4000, 0xc00034e000)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/router.go:81 +0x219
  |   | 2022-06-21 08:56:00 | net/http.serverHandler.ServeHTTP(0xc0001fe0e0, 0xab3cd0, 0xc0002e4000, 0xc00034e000)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:2887 +0xa3
  |   | 2022-06-21 08:56:00 | net/http.(*conn).serve(0xc0002a4000, 0xab4880, 0xc00039c000)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:1952 +0x8cd
  |   | 2022-06-21 08:56:00 | created by net/http.(*Server).Serve
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:3013 +0x39b
  |   | 2022-06-21 08:56:00 | goroutine 41251 [runnable]:
  |   | 2022-06-21 08:56:00 | net/http.(*conn).serve(0xc0002a41e0, 0xab4880, 0xc0001e6ff0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:1817
  |   | 2022-06-21 08:56:00 | created by net/http.(*Server).Serve
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:3013 +0x39b
  |   | 2022-06-21 08:56:00 | goroutine 41117 [IO wait]:
  |   | 2022-06-21 08:56:00 | internal/poll.runtime_pollWait(0x7f357628e920, 0x72, 0xffffffffffffffff)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/runtime/netpoll.go:222 +0x55
  |   | 2022-06-21 08:56:00 | internal/poll.(*pollDesc).wait(0xc0000fa018, 0x72, 0x0, 0x1, 0xffffffffffffffff)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
  |   | 2022-06-21 08:56:00 | internal/poll.(*pollDesc).waitRead(...)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
  |   | 2022-06-21 08:56:00 | internal/poll.(*FD).Read(0xc0000fa000, 0xc000078131, 0x1, 0x1, 0x0, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_unix.go:166 +0x1d5
  |   | 2022-06-21 08:56:00 | net.(*netFD).Read(0xc0000fa000, 0xc000078131, 0x1, 0x1, 0xc000413c80, 0x0, 0xc000022318)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/fd_posix.go:55 +0x4f
  |   | 2022-06-21 08:56:00 | net.(*conn).Read(0xc000010028, 0xc000078131, 0x1, 0x1, 0x0, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/net.go:183 +0x91
  |   | 2022-06-21 08:56:00 | net/http.(*connReader).backgroundRead(0xc000078120)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:692 +0x58
  |   | 2022-06-21 08:56:00 | created by net/http.(*connReader).startBackgroundRead
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:688 +0xd5
  |   | 2022-06-21 08:56:00 | goroutine 41216 [runnable]:
  |   | 2022-06-21 08:56:00 | compress/flate.(*compressor).init(0xc000800000, 0xaad100, 0xc0004fa000, 0xffffffffffffffff, 0xa, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/compress/flate/deflate.go:578 +0x9da
  |   | 2022-06-21 08:56:00 | compress/flate.NewWriter(0xaad100, 0xc0004fa000, 0xffffffffffffffff, 0xa, 0xa, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/compress/flate/deflate.go:671 +0x65
  |   | 2022-06-21 08:56:00 | compress/gzip.(*Writer).Write(0xc00022a210, 0xc000557200, 0x47e, 0x47e, 0x934ee0, 0xc0004fa001, 0xc0002d6000)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/compress/gzip/gzip.go:191 +0x305
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/gzip.(*gzipResponseWriter).Write(0xc0004bc0f0, 0xc000557200, 0x47e, 0x47e, 0xc0002d60b8, 0xc000574080, 0x20)
  |   | 2022-06-21 08:56:00 | /src/src/server/gzip/middleware.go:23 +0x4d
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server.(*Server).handleFeedIcon(0xc000186600, 0xc0002d0280)
  |   | 2022-06-21 08:56:00 | /src/src/server/routes.go:192 +0x478
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Context).Next(...)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/context.go:24
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/gzip.Middleware(0xc0002d0280)
  |   | 2022-06-21 08:56:00 | /src/src/server/gzip/middleware.go:42 +0x2ab
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Context).Next(...)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/context.go:24
  |   | 2022-06-21 08:56:00 | github.com/nkanaev/yarr/src/server/router.(*Router).ServeHTTP(0xc000022ac0, 0xab3cd0, 0xc0004fa000, 0xc00034e100)
  |   | 2022-06-21 08:56:00 | /src/src/server/router/router.go:81 +0x219
  |   | 2022-06-21 08:56:00 | net/http.serverHandler.ServeHTTP(0xc0001fe0e0, 0xab3cd0, 0xc0004fa000, 0xc00034e100)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:2887 +0xa3
  |   | 2022-06-21 08:56:00 | net/http.(*conn).serve(0xc0002a40a0, 0xab4880, 0xc0000221c0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:1952 +0x8cd
  |   | 2022-06-21 08:56:00 | created by net/http.(*Server).Serve
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:3013 +0x39b
  |   | 2022-06-21 08:56:00 | goroutine 41229 [IO wait]:
  |   | 2022-06-21 08:56:00 | internal/poll.runtime_pollWait(0x7f357628eaf0, 0x72, 0xffffffffffffffff)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/runtime/netpoll.go:222 +0x55
  |   | 2022-06-21 08:56:00 | internal/poll.(*pollDesc).wait(0xc00027a018, 0x72, 0x0, 0x1, 0xffffffffffffffff)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
  |   | 2022-06-21 08:56:00 | internal/poll.(*pollDesc).waitRead(...)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
  |   | 2022-06-21 08:56:00 | internal/poll.(*FD).Read(0xc00027a000, 0xc00029c0a1, 0x1, 0x1, 0x0, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_unix.go:166 +0x1d5
  |   | 2022-06-21 08:56:00 | net.(*netFD).Read(0xc00027a000, 0xc00029c0a1, 0x1, 0x1, 0xe209c0, 0xa44a38, 0xc0000d3fa8)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/fd_posix.go:55 +0x4f
  |   | 2022-06-21 08:56:00 | net.(*conn).Read(0xc00029a000, 0xc00029c0a1, 0x1, 0x1, 0x0, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/net.go:183 +0x91
  |   | 2022-06-21 08:56:00 | net/http.(*connReader).backgroundRead(0xc00029c090)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:692 +0x58
  |   | 2022-06-21 08:56:00 | created by net/http.(*connReader).startBackgroundRead
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:688 +0xd5
  |   | 2022-06-21 08:56:00 | goroutine 41236 [IO wait]:
  |   | 2022-06-21 08:56:00 | internal/poll.runtime_pollWait(0x7f357628ea08, 0x72, 0xffffffffffffffff)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/runtime/netpoll.go:222 +0x55
  |   | 2022-06-21 08:56:00 | internal/poll.(*pollDesc).wait(0xc000186018, 0x72, 0x0, 0x1, 0xffffffffffffffff)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
  |   | 2022-06-21 08:56:00 | internal/poll.(*pollDesc).waitRead(...)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
  |   | 2022-06-21 08:56:00 | internal/poll.(*FD).Read(0xc000186000, 0xc0001e61f1, 0x1, 0x1, 0x0, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/internal/poll/fd_unix.go:166 +0x1d5
  |   | 2022-06-21 08:56:00 | net.(*netFD).Read(0xc000186000, 0xc0001e61f1, 0x1, 0x1, 0x30000000065c09a, 0xc0004966c0, 0xaa43f0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/fd_posix.go:55 +0x4f
  |   | 2022-06-21 08:56:00 | net.(*conn).Read(0xc00058a008, 0xc0001e61f1, 0x1, 0x1, 0x0, 0x0, 0x0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/net.go:183 +0x91
  |   | 2022-06-21 08:56:00 | net/http.(*connReader).backgroundRead(0xc0001e61e0)
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:692 +0x58
  |   | 2022-06-21 08:56:00 | created by net/http.(*connReader).startBackgroundRead
  |   | 2022-06-21 08:56:00 | /usr/local/go/src/net/http/server.go:688 +0xd5
nkanaev commented 2 years ago

@minioin would you be able to confirm @quoing's changes fixed the issue?

nkanaev commented 2 years ago

marking as resolved. if the issue persists, ping me up & I'll reopen the ticket.