dragonflyoss / Dragonfly2

Dragonfly is an open source P2P-based file distribution and image acceleration system. It is hosted by the Cloud Native Computing Foundation (CNCF) as an Incubating Level Project.
https://d7y.io
Apache License 2.0
2.29k stars 292 forks source link

Error connecting to PostgreSQL database #3581

Closed RoLuoGan closed 4 weeks ago

RoLuoGan commented 1 month ago

Bug report:

Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: 2024-10-15T19:27:21.275+0800 INFO rpcserver/manager_server_v1.go:805 keepalive for the first time {"hostname": "tianjin034003.cluster.local", "ip": "10.4.34.3", "sourceType": "SEED_PEER_SOURCE", "clusterID": 1} Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: 2024-10-15T19:27:21.489+0800 ERROR recovery/interceptors.go:51 trace {"error": "ERROR: table name \"seed_peer\" specified more than once (SQLSTATE 42712)", "elapsed": "128.157602ms", "rows": 1, "sql": "UPDATE \"seed_peer\" SET \"updated_at\"='2024-10-15 19:27:21.403',\"state\"='active' FROM \"seed_peer\" WHERE (\"seed_peer\".\"host_name\" = 'tianjin034003.cluster.local' AND \"seed_peer\".\"ip\" = '10.4.34.3' AND \"seed_peer\".\"seed_peer_cluster_id\" = 1) AND \"seed_peer\".\"is_del\" = 0 AND \"id\" = 3"} Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-middleware/recovery.StreamServerInterceptor.func1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/recovery/interceptors.go:51 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.StreamServerInterceptor.func10 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/validator/validator.go:72 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-middleware/logging/zap.StreamServerInterceptor.func1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/logging/zap/server_interceptors.go:53 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-prometheus.init.(ServerMetrics).StreamServerInterceptor.func4 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-prometheus@v1.2.0/server_metrics.go:121 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.StreamServerInterceptor.func9 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/ratelimit/ratelimit.go:34 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:86 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(Server).processStreamingRPC Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1680 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(Server).handleStream Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1794 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(Server).serveStreams.func2.1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1029 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: 2024-10-15T19:27:21.489+0800 ERROR zap/server_interceptors.go:61 finished streaming call with code Internal {"grpc.start_time": "2024-10-15T19:27:16+08:00", "system": "grpc", "span.kind": "server", "grpc.service": "manager.Manager", "grpc.method": "KeepAlive", "error": "rpc error: code = Internal desc = ERROR: table name \"seed_peer\" specified more than once (SQLSTATE 42712)", "grpc.code": "Internal", "grpc.time_ms": 5215.655} Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-middleware/logging/zap.StreamServerInterceptor.func1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/logging/zap/server_interceptors.go:61 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-prometheus.init.(ServerMetrics).StreamServerInterceptor.func4 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-prometheus@v1.2.0/server_metrics.go:121 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.StreamServerInterceptor.func9 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/ratelimit/ratelimit.go:34 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:86 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(Server).processStreamingRPC Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1680 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(Server).handleStream Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1794 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(Server).serveStreams.func2.1 Oct 15 19:27:21 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1029 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: 2024-10-15T19:27:31.275+0800 INFO rpcserver/manager_server_v1.go:805 keepalive for the first time {"hostname": "tianjin034003.cluster.local", "ip": "10.4.34.3", "sourceType": "SEED_PEER_SOURCE", "clusterID": 1} Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: 2024-10-15T19:27:31.361+0800 ERROR recovery/interceptors.go:51 trace {"error": "record not found", "elapsed": "85.80663ms", "rows": 0, "sql": "SELECT FROM \"seed_peer\" WHERE (\"seed_peer\".\"host_name\" = 'tianjin034003.cluster.local' AND \"seed_peer\".\"ip\" = '10.4.34.3' AND \"seed_peer\".\"seed_peer_cluster_id\" = 1) AND \"seed_peer\".\"is_del\" = 0 ORDER BY \"seed_peer\".\"id\" LIMIT 1"} Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-middleware/recovery.StreamServerInterceptor.func1 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/recovery/interceptors.go:51 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.StreamServerInterceptor.func10 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/validator/validator.go:72 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-middleware/logging/zap.StreamServerInterceptor.func1 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/logging/zap/server_interceptors.go:53 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-prometheus.init.(ServerMetrics).StreamServerInterceptor.func4 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-prometheus@v1.2.0/server_metrics.go:121 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:83 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.StreamServerInterceptor.func9 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/ratelimit/ratelimit.go:34 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/chain.go:86 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(Server).processStreamingRPC Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1680 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(Server).handleStream Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1794 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: google.golang.org/grpc.(*Server).serveStreams.func2.1 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1029 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: 2024-10-15T19:27:31.361+0800 ERROR zap/server_interceptors.go:61 finished streaming call with code Internal {"grpc.start_time": "2024-10-15T19:27:26+08:00", "system": "grpc", "span.kind": "server", "grpc.service": "manager.Manager", "grpc.method": "KeepAlive", "error": "rpc error: code = Internal desc = record not found", "grpc.code": "Internal", "grpc.time_ms": 5085.884} Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: github.com/grpc-ecosystem/go-grpc-middleware/logging/zap.StreamServerInterceptor.func1 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: /root/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/logging/zap/server_interceptors.go:61 Oct 15 19:27:31 tianjin034003 run_manager.sh[5741]: d7y.io/dragonfly/v2/pkg/rpc/manager/server.New.ChainStreamServer.func12.1

Expected behavior:

How to reproduce it:

Environment:

gaius-qi commented 1 month ago

@RoLuoGan https://github.com/go-gorm/gorm/issues/7055, https://github.com/go-gorm/gorm/issues/6929

You can change the code to Session. https://gorm.io/docs/method_chaining.html#New-Session-Methods

andreineustroev commented 1 month ago

For now downgrade dependencies working solution.

    gorm.io/driver/mysql v1.4.7
    gorm.io/driver/postgres v1.4.8
    gorm.io/gorm v1.24.6