Closed tsynik closed 2 months ago
Describe the bug Server fails after adding torrent or set viewed
Log
2024/04/07 19:10:08 UTC0 save to db: 26a2c3105c90572f760c0b844712fb14a3afc321 2024/04/07 19:10:13 UTC0 Preload: 26a2c3105c90572f760c0b844712fb14a3afc321 63.30MB/32.00MB Speed:30B Peers:25/146 [Seeds:20] fatal error: concurrent map read and map write goroutine 11925945 [running]: server/settings.(*DBReadCache).Get(0x8210edf0, {0x7ed50e56, 0x8}, {0x702e0240, 0x28}) /Users/yourok/Projects/GO/TorrServer/server/settings/dbreadcache.go:29 +0x54 server/settings.ListTorrent() /Users/yourok/Projects/GO/TorrServer/server/settings/torrent.go:62 +0x150 server/torr.ListTorrentsDB() /Users/yourok/Projects/GO/TorrServer/server/torr/dbwrapper.go:69 +0x20 server/torr.ListTorrent() /Users/yourok/Projects/GO/TorrServer/server/torr/apihelper.go:165 +0x120 server/web/api.listTorrent({{{0x87ecece0, 0x4}}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...) /Users/yourok/Projects/GO/TorrServer/server/web/api/torrents.go:171 +0x14 server/web/api.torrents(0x7bb54328) /Users/yourok/Projects/GO/TorrServer/server/web/api/torrents.go:69 +0x218 github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0x7bb54328) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 +0x9c github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 server/web/blocker.Blocker.func1(0x7bb54328) /Users/yourok/Projects/GO/TorrServer/server/web/blocker/blocker.go:21 +0x3c github.com/gin-gonic/gin.(*Context).Next(0x7bb54328) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x38 server/web.Start.WebLogger.func3(0x7bb54328) /Users/yourok/Projects/GO/TorrServer/server/log/log.go:90 +0x36c github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0x8218e2a8, 0x7bb54328) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x56c github.com/gin-gonic/gin.(*Engine).ServeHTTP(0x8218e2a8, {0x7f89c5b4, 0x857d1c28}, 0x857d1b88) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1bc net/http.serverHandler.ServeHTTP({0x820ec328}, {0x7f89c5b4, 0x857d1c28}, 0x857d1b88) /usr/local/go/src/net/http/server.go:3137 +0xf4 net/http.(*conn).serve(0x8240a540, {0x7f89d410, 0x822e9488}) /usr/local/go/src/net/http/server.go:2039 +0x670 created by net/http.(*Server).Serve in goroutine 53 /usr/local/go/src/net/http/server.go:3285 +0x4c0
2024/04/09 17:16:14 UTC0 Preload: c09b3527271eaf2725c054ca556895f42d11e69d 31.61MB/32.00MB Speed:580.18KB Peers:10/34 [Seeds:8] 2024/04/09 17:16:15 UTC0 End preload: c09b3527271eaf2725c054ca556895f42d11e69d Peers: 10 / 34 [ Seeds: 8 ] fatal error: concurrent map read and map write goroutine 2173643 [running]: server/settings.(*DBReadCache).Get(0x8780e300, {0x83e15e56, 0x8}, {0x58c72270, 0x28}) /Users/yourok/Projects/GO/TorrServer/server/settings/dbreadcache.go:29 +0x54 server/settings.ListTorrent() /Users/yourok/Projects/GO/TorrServer/server/settings/torrent.go:62 +0x150 server/torr.ListTorrentsDB() /Users/yourok/Projects/GO/TorrServer/server/torr/dbwrapper.go:69 +0x20 server/torr.ListTorrent() /Users/yourok/Projects/GO/TorrServer/server/torr/apihelper.go:165 +0x120 server/web/api.listTorrent({{{0x8eec69f0, 0x4}}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...) /Users/yourok/Projects/GO/TorrServer/server/web/api/torrents.go:171 +0x14 server/web/api.torrents(0x68c1d188) /Users/yourok/Projects/GO/TorrServer/server/web/api/torrents.go:69 +0x218 github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0x68c1d188) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 +0x9c github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 server/web/blocker.Blocker.func1(0x68c1d188) /Users/yourok/Projects/GO/TorrServer/server/web/blocker/blocker.go:21 +0x3c github.com/gin-gonic/gin.(*Context).Next(0x68c1d188) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x38 server/web.Start.WebLogger.func3(0x68c1d188) /Users/yourok/Projects/GO/TorrServer/server/log/log.go:90 +0x36c github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0x878dcc48, 0x68c1d188) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x56c github.com/gin-gonic/gin.(*Engine).ServeHTTP(0x878dcc48, {0x849615b4, 0x68c1d0e8}, 0x68c1d048) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1bc net/http.serverHandler.ServeHTTP({0x87898aa8}, {0x849615b4, 0x68c1d0e8}, 0x68c1d048) /usr/local/go/src/net/http/server.go:3137 +0xf4 net/http.(*conn).serve(0x87bf2120, {0x84962410, 0x87895428}) /usr/local/go/src/net/http/server.go:2039 +0x670 created by net/http.(*Server).Serve in goroutine 28 /usr/local/go/src/net/http/server.go:3285 +0x4c0
fatal error: concurrent map writes fatal error: concurrent map writes goroutine 2807244 [running]: server/settings.(*DBReadCache).Set(0xad82980, {0x71ffd2c, 0x6}, {0xadb65d0, 0x28}, {0x268ca5b8, 0x16, 0x18}) /Users/yourok/Projects/GO/TorrServer/server/settings/dbreadcache.go:43 +0x68 server/settings.SetViewed(0xc539a68) /Users/yourok/Projects/GO/TorrServer/server/settings/viewed.go:32 +0x28c server/torr.(*Torrent).Stream(0xadd2548, 0x3, 0x27315868, {0xe94b1c30, 0xcdec3c8}) /Users/yourok/Projects/GO/TorrServer/server/torr/stream.go:66 +0x75c server/web/api.stream(0xcdec3c8) /Users/yourok/Projects/GO/TorrServer/server/web/api/stream.go:157 +0x920 github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0xcdec3c8) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 +0x9c github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 server/web/blocker.Blocker.func1(0xcdec3c8) /Users/yourok/Projects/GO/TorrServer/server/web/blocker/blocker.go:21 +0x3c github.com/gin-gonic/gin.(*Context).Next(0xcdec3c8) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x38 server/web.Start.WebLogger.func3(0xcdec3c8) /Users/yourok/Projects/GO/TorrServer/server/log/log.go:90 +0x36c github.com/gin-gonic/gin.(*Context).Next(...) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xad460e8, 0xcdec3c8) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x56c github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xad460e8, {0x7d505b4, 0xcded688}, 0x27315868) /Users/yourok/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1bc net/http.serverHandler.ServeHTTP({0xad28328}, {0x7d505b4, 0xcded688}, 0x27315868) /usr/local/go/src/net/http/server.go:3137 +0xf4 net/http.(*conn).serve(0xacaa660, {0x7d51410, 0xac42e40}) /usr/local/go/src/net/http/server.go:2039 +0x670 created by net/http.(*Server).Serve in goroutine 76 /usr/local/go/src/net/http/server.go:3285 +0x4c0
Desktop:
@filimonic any thoughts? Is this enough to add sync.RWmutex like this? https://github.com/YouROK/TorrServer/commit/9f93de63056605a4c27c303509c1ee3fed26c894
probably fixed in 131 release
Describe the bug Server fails after adding torrent or set viewed
Log
Desktop:
@filimonic any thoughts? Is this enough to add sync.RWmutex like this? https://github.com/YouROK/TorrServer/commit/9f93de63056605a4c27c303509c1ee3fed26c894