(pool *client.Pool)
| 124 | } |
| 125 | |
| 126 | func (m *mysqlProxy) popConn(pool *client.Pool) (*client.Conn, error) { |
| 127 | var mysqlConn *client.Conn |
| 128 | var err error |
| 129 | for i := 0; i < GetConnRetry; i++ { |
| 130 | mysqlConn, err = pool.GetConn(m.ctx) |
| 131 | if err != nil { |
| 132 | continue |
| 133 | } |
| 134 | err = mysqlConn.Ping() |
| 135 | if err != nil { |
| 136 | continue |
| 137 | } |
| 138 | |
| 139 | if mysqlConn.IsInTransaction() { |
| 140 | if err := mysqlConn.Rollback(); err != nil { |
| 141 | mysqlConn.Close() |
| 142 | continue |
| 143 | } |
| 144 | } |
| 145 | if !mysqlConn.IsAutoCommit() { |
| 146 | if err := mysqlConn.SetAutoCommit(true); err != nil { |
| 147 | mysqlConn.Close() |
| 148 | continue |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | if mysqlConn.GetCharset() != mysql.DEFAULT_CHARSET { |
| 153 | if err := mysqlConn.SetCharset(mysql.DEFAULT_CHARSET); err != nil { |
| 154 | mysqlConn.Close() |
| 155 | continue |
| 156 | } |
| 157 | } |
| 158 | break |
| 159 | } |
| 160 | return mysqlConn, nil |
| 161 | } |
| 162 | |
| 163 | func (m *mysqlProxy) pushAdminConn(mysqlConn *client.Conn, err error) { |
| 164 | m.pushConn(mysqlConn, err, m.adminPool) |
no test coverage detected