An error occurred after the mysql active/standby switch:The MySQL server is running with the --read-only option so it cannot execute this statement
- Dominant language
- Go
- Stars
- 538
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
## GORM Playground Link
https://github.com/go-gorm/playground/pull/1
## Description
1、Stop the main library directly, and then switch between main and standby
2、log print: The MySQL server is running with the --read-only option so it cannot execute this statement
3、The read_only parameter confirms that it has been set to 0
4、 mysql 5.6
**dsn: master**
**db2Dsn: slave**
`
err = db.Use(dbresolver.Register(dbresolver.Config{
Replicas: []gorm.Dialector{mysql.Open(db2Dsn), mysql.Open(dsn)},
// sources/replicas 负载均衡策略, 默认随机
// todo - 比例随机均匀, 读主 读从. 如需调整,需要自定义 Policy
Policy: dbresolver.RandomPolicy{},
}, tabs...).
SetMaxOpenConns(slaveCnf.MaxOpenCons).
SetMaxIdleConns(slaveCnf.MaxIdleCons).
SetConnMaxLifetime(time.Duration(slaveCnf.MaxLifetime) * time.Second))
`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.