Open
Description
#656
同这个帖子里面的问题有点类似
在多一个请求的时候报错fatal error: concurrent map read and map write
作者,请看我日志
2025-06-17 12:07:29.800+0800 ::1 125.7593ms info GET middleware/logger.go 200 /api/admin/v1/notice/list?pageIndex=1&pageSize=10 4e170148-afa9-4924-ba94-364b6f7963c8
fatal error: concurrent map read and map write
goroutine 225 [running]:
sync.(*Map).Swap(0xc002284ba0, {0x22c18a0, 0xc002292fa0}, {0x22c18a0, 0xc002292f90})
C:/Users/Administrator/.g/go/src/sync/map.go:353 +0x385
sync.(*Map).Store(0xc002284ba0, {0x22c18a0, 0xc002292fa0}, {0x22c18a0, 0xc002292f90})
C:/Users/Administrator/.g/go/src/sync/map.go:155 +0x51
github.com/go-admin-team/go-admin-core/server/grpc/interceptors/logging/ctxlog.(*Fields).Set(0xc002284ba0, {0x2723bd1, 0xb}, {0x22c18a0, 0xc002292f90})
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/server/grpc/interceptors/logging/ctxlog/fields.go:53 +0x5e
github.com/go-admin-team/go-admin-core/server/grpc/interceptors/logging.newClientLoggerFields({0x3048120, 0xc002284b40}, {0x2772c4f, 0x2c})
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/server/grpc/interceptors/logging/client_interceptors.go:79 +0x1bf
github.com/go-admin-team/go-admin-core/server/grpc/interceptors/logging.UnaryClientInterceptor.func1({0x3048120, 0xc002284b40}, {0x2772c4f, 0x2c}, {0x25964c0, 0xc00228e1c0}, {0x25965a0, 0xc0022849f0}, 0xc001057c08, 0xc002284a20, ...)
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/server/grpc/interceptors/logging/client_interceptors.go:34 +0xb2
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryClient.func2.1({0x3048120, 0xc002284b40}, {0x2772c4f, 0x2c}, {0x25964c0, 0xc00228e1c0}, {0x25965a0, 0xc0022849f0}, 0xc001057c08, {0xc0004a7f60, ...})
D:/go_projects/pkg/mod/github.com/grpc-ecosystem/[email protected]/chain.go:113 +0x16e
github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing.UnaryClientInterceptor.func1({0x3048120, 0xc0022849c0}, {0x2772c4f, 0x2c}, {0x25964c0, 0xc00228e1c0}, {0x25965a0, 0xc0022849f0}, 0xc001057c08, 0xc002284a50, ...)
D:/go_projects/pkg/mod/github.com/grpc-ecosystem/[email protected]/tracing/opentracing/client_interceptors.go:31 +0x348
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryClient.func2({0x3048120, 0xc0022849c0}, {0x2772c4f, 0x2c}, {0x25964c0, 0xc00228e1c0}, {0x25965a0, 0xc0022849f0}, 0xc001057c08, 0x2f17990, ...)
D:/go_projects/pkg/mod/github.com/grpc-ecosystem/[email protected]/chain.go:116 +0x279
google.golang.org/grpc.(*ClientConn).Invoke(0xc001057c08, {0x3048120, 0xc0022849c0}, {0x2772c4f, 0x2c}, {0x25964c0, 0xc00228e1c0}, {0x25965a0, 0xc0022849f0}, {0xc0004a7f60, ...})
D:/go_projects/pkg/mod/google.golang.org/[email protected]/call.go:35 +0x192
gitlab.n2games.com/platform-engineering/gp-api/gen/bucket/v1.(*globalConfigServiceClient).GetGameConfig(0xc002292440, {0x3048120, 0xc0022849c0}, 0xc00228e1c0, {0x0, 0x0, 0x0})
D:/go_projects/pkg/mod/gitlab.n2games.com/platform-engineering/[email protected]/gen/bucket/v1/global_config_grpc.pb.go:75 +0xf7
gmgo-admin/app/nos/apis.GlobalConfig.GetGameConfig.func1({0x3048af8, 0xc002292440}, {0x3048120, 0xc0022849c0}, 0xc00228e1c0)
D:/go_projects/src/nominox-admin-service/app/nos/apis/global_config.go:95 +0x95
gmgo-admin/pkg.ProxyImpl[...](0xc000495700, 0xc00052e180, 0x2f15fb0, 0x0)
D:/go_projects/src/nominox-admin-service/pkg/grpc.go:167 +0xfd4
gmgo-admin/app/nos/apis.GlobalConfig.GetGameConfig({{0x0, 0x0, 0x0, 0x0, 0x0, {0x0, 0x0}, {0x0, 0x0}}}, 0xc000495700)
D:/go_projects/src/nominox-admin-service/app/nos/apis/global_config.go:91 +0xaf
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.AuthCheckRole.func1(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/permission.go:26 +0x1aa
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth.(*GinJWTMiddleware).middlewareImpl(0xc001b1e820, 0xc000495700)
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/sdk/pkg/jwtauth/jwtauth.go:460 +0x871
github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth.(*GinJWTMiddleware).MiddlewareFunc.func1(0xc000495700)
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/sdk/pkg/jwtauth/jwtauth.go:397 +0x26
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.ApprovalProcess.func1(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/approval.go:79 +0x121c
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.Options(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/header.go:24 +0x14d
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.NoCache(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/header.go:16 +0xc5
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.CustomError(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/customerror.go:60 +0x7c
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.LoggerToFile.func1(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/logger.go:45 +0x605
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.WithContextDb(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/db.go:22 +0x274
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.DemoEvn.func1(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/demo.go:27 +0x99b
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
gmgo-admin/common/middleware.RequestId.func1(0xc000495700)
D:/go_projects/src/nominox-admin-service/common/middleware/request_id.go:34 +0x472
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
github.com/alibaba/sentinel-golang/pkg/adapters/gin.SentinelMiddleware.func1(0xc000495700)
D:/go_projects/pkg/mod/github.com/alibaba/sentinel-golang/pkg/adapters/[email protected]/middleware.go:40 +0x2e5
github.com/gin-gonic/gin.(*Context).Next(0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 +0x7a
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc001b1e1a0, 0xc000495700)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:620 +0x42a
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc001b1e1a0, {0x30436d0, 0xc001042b60}, 0xc001e80a20)
D:/go_projects/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:576 +0xbc
net/http.serverHandler.ServeHTTP({0xc000108b40}, {0x30436d0, 0xc001042b60}, 0xc001e80a20)
C:/Users/Administrator/.g/go/src/net/http/server.go:3142 +0x257
net/http.(*conn).serve(0xc000fcb3b0, {0x3048158, 0xc001b85ef0})
C:/Users/Administrator/.g/go/src/net/http/server.go:2044 +0x1ab5
created by net/http.(*Server).Serve in goroutine 121
C:/Users/Administrator/.g/go/src/net/http/server.go:3290 +0xa9a
goroutine 1 [chan receive]:
gmgo-admin/cmd/api.run()
D:/go_projects/src/nominox-admin-service/cmd/api/server.go:142 +0x1066
gmgo-admin/cmd/api.init.func2(0x4977c20, {0xc001180e40, 0x0, 0x2})
D:/go_projects/src/nominox-admin-service/cmd/api/server.go:45 +0x2c
github.com/spf13/cobra.(*Command).execute(0x4977c20, {0xc001180e00, 0x2, 0x2})
D:/go_projects/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0xcbb
github.com/spf13/cobra.(*Command).ExecuteC(0x49770a0)
D:/go_projects/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x990
github.com/spf13/cobra.(*Command).Execute(0x49770a0)
D:/go_projects/pkg/mod/github.com/spf13/[email protected]/command.go:992 +0x32
gmgo-admin/cmd.Execute()
D:/go_projects/src/nominox-admin-service/cmd/cobra.go:67 +0x1a
main.main()
D:/go_projects/src/nominox-admin-service/main.go:24 +0xf
goroutine 100 [select]:
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*rttMonitor).runHellos(0xc000fcabd0, 0xc0004ff088)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/rtt_monitor.go:156 +0x17d
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*rttMonitor).start(0xc000fcabd0)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/rtt_monitor.go:130 +0x1ff
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*rttMonitor).connect.func1()
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/rtt_monitor.go:90 +0x8c
created by go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*rttMonitor).connect in goroutine 31
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/rtt_monitor.go:87 +0x110
goroutine 13 [syscall, locked to thread]:
syscall.SyscallN(0x7ffe0bef6110, {0xc00140b958?, 0x6, 0x7ffe0bef6110?})
C:/Users/Administrator/.g/go/src/runtime/syscall_windows.go:544 +0x11d
syscall.Syscall6(0xc001095ef0?, 0xc0004836c0?, 0xc00140ba18?, 0x7b591?, 0xc0000508d8?, 0xc00120f8c0?, 0xc001205ec0?, 0xc00140ba08?)
C:/Users/Administrator/.g/go/src/runtime/syscall_windows.go:488 +0x4a
golang.org/x/sys/windows.GetQueuedCompletionStatus(0x1e4, 0xc00140baac, 0xc00140bac8, 0xc00140bb78, 0xffffffff)
D:/go_projects/pkg/mod/golang.org/x/[email protected]/windows/zsyscall_windows.go:2561 +0xc5
github.com/fsnotify/fsnotify.(*Watcher).readEvents(0xc00109fa40)
D:/go_projects/pkg/mod/github.com/fsnotify/[email protected]/backend_windows.go:650 +0x7d
created by github.com/fsnotify/fsnotify.NewBufferedWatcher in goroutine 26
D:/go_projects/pkg/mod/github.com/fsnotify/[email protected]/backend_windows.go:176 +0x33c
goroutine 26 [select]:
github.com/go-admin-team/go-admin-core/config/source/file.(*watcher).Next(0xc00011ca08)
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/source/file/watcher.go:46 +0x1a5
github.com/go-admin-team/go-admin-core/config/loader/memory.(*memory).watch.func1(0x0, {0x303e2b8, 0xc00011ca08})
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/loader/memory/memory.go:54 +0x75
github.com/go-admin-team/go-admin-core/config/loader/memory.(*memory).watch(0xc000d45970, 0x0, {0x3048548, 0xc0003b7260})
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/loader/memory/memory.go:104 +0x262
created by github.com/go-admin-team/go-admin-core/config/loader/memory.(*memory).Load in goroutine 1
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/loader/memory/memory.go:324 +0x685
goroutine 60 [select]:
github.com/go-admin-team/go-admin-core/config/loader/memory.(*memory).watch.func2()
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/loader/memory/memory.go:96 +0xbb
created by github.com/go-admin-team/go-admin-core/config/loader/memory.(*memory).watch in goroutine 26
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/loader/memory/memory.go:95 +0x245
goroutine 27 [select]:
github.com/go-admin-team/go-admin-core/config/loader/memory.(*watcher).Next(0xc00108e060)
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/loader/memory/memory.go:393 +0x165
github.com/go-admin-team/go-admin-core/config.(*config).run.func1({0x303feb0, 0xc00108e060})
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/default.go:88 +0x69
github.com/go-admin-team/go-admin-core/config.(*config).run(0xc00121e3f0)
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/default.go:133 +0x23b
created by github.com/go-admin-team/go-admin-core/config.newConfig in goroutine 1
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/default.go:40 +0x150
goroutine 45 [chan receive]:
github.com/go-admin-team/go-admin-core/config/loader/memory.(*memory).Watch.func1()
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/loader/memory/memory.go:360 +0x48
created by github.com/go-admin-team/go-admin-core/config/loader/memory.(*memory).Watch in goroutine 27
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/loader/memory/memory.go:359 +0x445
goroutine 46 [select]:
github.com/go-admin-team/go-admin-core/config.(*config).run.func2()
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/default.go:125 +0xbb
created by github.com/go-admin-team/go-admin-core/config.(*config).run in goroutine 27
D:/go_projects/src/nominox-admin-service/libs/go-admin-core/config/default.go:124 +0x227
goroutine 28 [sync.Cond.Wait]:
sync.runtime_notifyListWait(0xc0000c1c90, 0x3)
C:/Users/Administrator/.g/go/src/runtime/sema.go:569 +0x15c
sync.(*Cond).Wait(0xc0000c1c80)
C:/Users/Administrator/.g/go/src/sync/cond.go:70 +0x6f
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).createConnections.func2()
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:1167 +0x185
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).createConnections(0xc0003ff080, {0x3048158, 0xc000560dc0}, 0xc000d67e30)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:1189 +0x299
created by go.mongodb.org/mongo-driver/x/mongo/driver/topology.newPool in goroutine 1
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:245 +0xa09
goroutine 29 [sync.Cond.Wait]:
sync.runtime_notifyListWait(0xc0000c1c90, 0x4)
C:/Users/Administrator/.g/go/src/runtime/sema.go:569 +0x15c
sync.(*Cond).Wait(0xc0000c1c80)
C:/Users/Administrator/.g/go/src/sync/cond.go:70 +0x6f
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).createConnections.func2()
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:1167 +0x185
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).createConnections(0xc0003ff080, {0x3048158, 0xc000560dc0}, 0xc000d67e30)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:1189 +0x299
created by go.mongodb.org/mongo-driver/x/mongo/driver/topology.newPool in goroutine 1
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:245 +0xa09
goroutine 30 [select]:
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).maintain(0xc0003ff080, {0x3048158, 0xc000560dc0}, 0xc000d67e30)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:1301 +0x398
created by go.mongodb.org/mongo-driver/x/mongo/driver/topology.newPool in goroutine 1
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:252 +0xb65
goroutine 31 [IO wait]:
internal/poll.runtime_pollWait(0x182f6464e50, 0x72)
C:/Users/Administrator/.g/go/src/runtime/netpoll.go:345 +0x3c
internal/poll.(*pollDesc).wait(0xc0000eabc0, 0x72, 0x0)
C:/Users/Administrator/.g/go/src/internal/poll/fd_poll_runtime.go:84 +0x7a
internal/poll.execIO(0xc0000eaa20, 0x2f149a8)
C:/Users/Administrator/.g/go/src/internal/poll/fd_windows.go:175 +0x2b8
internal/poll.(*FD).Read(0xc0000eaa08, {0xc000e70298, 0x4, 0x4})
C:/Users/Administrator/.g/go/src/internal/poll/fd_windows.go:436 +0x4b8
net.(*netFD).Read(0xc0000eaa08, {0xc000e70298, 0x4, 0x4})
C:/Users/Administrator/.g/go/src/net/fd_posix.go:55 +0x73
net.(*conn).Read(0xc00141e000, {0xc000e70298, 0x4, 0x4})
C:/Users/Administrator/.g/go/src/net/net.go:185 +0xa5
io.ReadAtLeast({0x182fb80d338, 0xc00141e000}, {0xc000e70298, 0x4, 0x4}, 0x4)
C:/Users/Administrator/.g/go/src/io/io.go:335 +0x168
io.ReadFull({0x182fb80d338, 0xc00141e000}, {0xc000e70298, 0x4, 0x4})
C:/Users/Administrator/.g/go/src/io/io.go:354 +0x93
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*connection).read(0xc0004fedc8, {0x3048158, 0xc0010a80f0})
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/connection.go:524 +0x42d
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*connection).readWireMessage(0xc0004fedc8, {0x3048158, 0xc0010a80f0})
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/connection.go:453 +0x4dc
go.mongodb.org/mongo-driver/x/mongo/driver/topology.initConnection.ReadWireMessage({0xc0004fedc8}, {0x3048158, 0xc0010a80f0})
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/connection.go:694 +0x79
go.mongodb.org/mongo-driver/x/mongo/driver.Operation.readWireMessage({0xc000c49b10, {0x2709141, 0x5}, {0x303ee20, 0xc000c49af0}, 0xc000c49b40, {0x0, 0x0}, 0x0, 0x0, ...}, ...)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/operation.go:1103 +0xa2
go.mongodb.org/mongo-driver/x/mongo/driver.Operation.roundTrip({0xc000c49b10, {0x2709141, 0x5}, {0x303ee20, 0xc000c49af0}, 0xc000c49b40, {0x0, 0x0}, 0x0, 0x0, ...}, ...)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/operation.go:1099 +0x1db
go.mongodb.org/mongo-driver/x/mongo/driver.Operation.Execute({0xc000c49b10, {0x2709141, 0x5}, {0x303ee20, 0xc000c49af0}, 0xc000c49b40, {0x0, 0x0}, 0x0, 0x0, ...}, ...)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/operation.go:810 +0x2514
go.mongodb.org/mongo-driver/x/mongo/driver/operation.(*Hello).Execute(0xc000d45c30, {0x3048158, 0xc0010a80f0})
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/operation/hello.go:567 +0xd8
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Server).check(_)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/server.go:881 +0x6fa
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Server).update(0xc000fb8b40)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/server.go:605 +0x509
created by go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Server).Connect in goroutine 1
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/server.go:252 +0x239
goroutine 32 [sync.Cond.Wait]:
sync.runtime_notifyListWait(0xc0000c1d10, 0x0)
C:/Users/Administrator/.g/go/src/runtime/sema.go:569 +0x15c
sync.(*Cond).Wait(0xc0000c1d00)
C:/Users/Administrator/.g/go/src/sync/cond.go:70 +0x6f
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).createConnections.func2()
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:1167 +0x185
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).createConnections(0xc0003ff200, {0x3048158, 0xc000560eb0}, 0xc000d67ea0)
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:1189 +0x299
created by go.mongodb.org/mongo-driver/x/mongo/driver/topology.newPool in goroutine 1
D:/go_projects/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:245 +0xa09
看调用栈最上方好像是说go-admin-core中的server/grpc/interceptors/logging/ctxlog/fields.go报的错
现代码如下
/*
* @Author: jasonhuang
* @Date: 2021/5/19 11:42 上午
* @Last Modified by: jasonhuang
* @Last Modified time: 2021/5/19 11:42 上午
*/
package ctxlog
import "sync"
//type Fields struct {
// value map[string]interface{}
//}
//
//func NewFields(key string, value interface{}) *Fields {
// f := &Fields{}
// f.Set(key, value)
// return f
//}
//
//func (e *Fields) Set(key string, value interface{}) {
// if e.value == nil {
// e.value = make(map[string]interface{})
// }
// e.value[key] = value
//}
//
//func (e *Fields) Values() map[string]interface{} {
// return e.value
//}
//
//func (e *Fields) Merge(f *Fields) {
// if len(f.value) > 0 {
// for k, v := range f.value {
// e.Set(k, v)
// }
// }
//}
type Fields struct {
value sync.Map
}
func NewFields(key string, value interface{}) *Fields {
f := &Fields{}
f.Set(key, value)
return f
}
func (e *Fields) Set(key string, value interface{}) {
e.value.Store(key, value)
}
func (e *Fields) Values() map[string]interface{} {
result := make(map[string]interface{})
e.value.Range(func(k, v interface{}) bool {
result[k.(string)] = v
return true
})
return result
}
func (e *Fields) Merge(f *Fields) {
if f == nil {
return
}
f.value.Range(func(k, v interface{}) bool {
e.value.Store(k.(string), v)
return true
})
}
而且奇怪的是往往是在服务初次重启,刷新网页一次调五六个接口的时候会报错, 但是第一次不报错的情况下,后续刷新网页都没出现这个报错
被注释的是你之前写的代码, 后面的是我改的sync.Map,也是并发报错,作者大大,帮我
Metadata
Metadata
Assignees
Labels
No labels