Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getShardConns 有个小BUG #23

Open
dancebear opened this issue Sep 15, 2014 · 1 comment
Open

getShardConns 有个小BUG #23

dancebear opened this issue Sep 15, 2014 · 1 comment

Comments

@dancebear
Copy link
Contributor

getShardConns函数会被handleExec和handleSelect等调用;这里handleExec可能会执行Insert或者update,在getShareConns中进行获取数据库连接处理时调用了getConn方法来获取数据库连接,

    var co *client.SqlConn
    for _, n := range nodes {
        co, err = c.getConn(n, true)
        if err != nil {
            break
        }
        conns = append(conns, co)
}

而getConn是根据isSelect参数来判断是在主上执行操作还是在从上执行操作,现在问题出来了

co, err = c.getConn(n, true)

这里的isSelect参数始终是true。
结果就是如果你的从库设置了只读,那么就无法进行写操作;他将返回:
ERROR 1290 (HY000): The MariaDB server is running with the --read-only option so it cannot execute this statement

@siddontang
Copy link
Owner

Thank you very much. I will try to check and fix it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants