go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly
https://gorm.io
MIT License
37.05k stars 3.94k forks source link

连接PgSql时,DisableAutomaticPing设置为true,但还是会触发--ping命令,并且连接不断开,导致连接数一直在增加 #7196

Closed meichuanneiku closed 2 months ago

meichuanneiku commented 2 months ago

场景: 在使用go-kratos框架中实现一个定时任务,该任务会查询pgsql中的数据,因此会在项目启动时创建pgsql的连接,在连接的配置信息中DisableAutomaticPing设置为true,企图关闭自动ping的功能

问题: 但在运行一段时间(大概1天),发现pg数据库无法连接,就查询数据库的连接状态,发现--ping命令的连接未断开并且数量还一直在增加。之后就尝试修改连接池的数量,不管修改多少,问题仍然存在

使用版本: go:1.22.4 gorm: 1.25.12

查询数据库连接状态截图:

联想截图_20240918101050 联想截图_20240918101418

示例代码项目: https://github.com/meichuanneiku/connentgorm.git

github-actions[bot] commented 2 months ago

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

github-actions[bot] commented 2 months ago

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

meichuanneiku commented 2 months ago

实现了一个测试demo https://github.com/meichuanneiku/connentgorm.git

github-actions[bot] commented 2 months ago

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

github-actions[bot] commented 2 months ago

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

github-actions[bot] commented 2 months ago

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

github-actions[bot] commented 2 months ago

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

ivila commented 2 months ago

@meichuanneiku 你这样提issue的方式是不正确的,你提的demo也应该是gorm就可以复现的问题,而不是给出一个使用复杂的巨型框架的demo代码(并且里面还没有明显的gorm是如何连接的说明)。 你应该给出一个gorm就可复现的demo,这样大家才能快速地帮你找到问题并解决,而不是先浪费时间去找你的一大堆信息里面有哪些是有用的(更别说你的demo里面还引入了一大堆额外变量)

github-actions[bot] commented 2 months ago

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking