如何关闭Ruby on Rails MySQL2会话查询

时间:2014-11-17 15:26:38

标签: ruby-on-rails-4

我正在尝试将Ruby on Rails应用程序连接到dbShards数据库。他们的数据库关闭会话变量以优化分片性能。因此,当我尝试运行该应用程序时,我收到此错误:

2014-11-17 08:23:29,647 ERROR c.d.s.SQLParser [NioServer-WorkerPool-2] Failed to parse SET NAMES utf8,  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 21
47483, @@SESSION.sql_mode = 'STRICT_ALL_TABLES'
 java.sql.SQLException: Session variables are not shard-safe
        at com.dbshards.sqlparsernew.SQLParser.parseSet(SQLParser.java:558)
        at com.dbshards.sqlparsernew.SQLParser.parse(SQLParser.java:402)
        at com.dbshards.sqlparsernew.SQLParserCache.parse(SQLParserCache.java:79)
        at com.dbshards.jdbc.sharding.DbsShardedStatement.execute(DbsShardedStatement.java:388)
        at com.dbshards.osp.client.impl.processor.JDBCProcessor.execute(JDBCProcessor.java:321)
        at com.dbshards.osp.client.impl.myosp.MyOSPProtocolHandler.processQueryRequest(MyOSPProtocolHandler.java:876)
        at com.dbshards.osp.client.impl.myosp.MyOSPProtocolHandler.doProcessBuffer(MyOSPProtocolHandler.java:518)
        at com.dbshards.osp.client.impl.myosp.MyOSPProtocolHandler.processBuffer(MyOSPProtocolHandler.java:1520)
        at com.codefutures.common.messaging.transport.nio.NioConnection.doRead(NioConnection.java:127)
        at com.codefutures.common.messaging.transport.nio.NioServer.doProcessRequests(NioServer.java:556)
        at com.codefutures.common.messaging.transport.nio.NioServer.access$200(NioServer.java:25)
        at com.codefutures.common.messaging.transport.nio.NioServer$2.run(NioServer.java:534)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

即使我在database.yml中设置strict:false,这也是我得到的:

2014-11-17 12:11:11,229 ERROR c.d.s.SQLParser [NioServer-WorkerPool-12] Failed to parse SET NAMES utf8,  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 21
47483, @@SESSION.sql_mode = ''
 java.sql.SQLException: Session variables are not shard-safe
        at com.dbshards.sqlparsernew.SQLParser.parseSet(SQLParser.java:558)
        at com.dbshards.sqlparsernew.SQLParser.parse(SQLParser.java:402)
        at com.dbshards.sqlparsernew.SQLParserCache.parse(SQLParserCache.java:79)
        at com.dbshards.jdbc.sharding.DbsShardedStatement.execute(DbsShardedStatement.java:388)
        at com.dbshards.osp.client.impl.processor.JDBCProcessor.execute(JDBCProcessor.java:321)
        at com.dbshards.osp.client.impl.myosp.MyOSPProtocolHandler.processQueryRequest(MyOSPProtocolHandler.java:876)
        at com.dbshards.osp.client.impl.myosp.MyOSPProtocolHandler.doProcessBuffer(MyOSPProtocolHandler.java:518)
        at com.dbshards.osp.client.impl.myosp.MyOSPProtocolHandler.processBuffer(MyOSPProtocolHandler.java:1520)
        at com.codefutures.common.messaging.transport.nio.NioConnection.doRead(NioConnection.java:127)
        at com.codefutures.common.messaging.transport.nio.NioServer.doProcessRequests(NioServer.java:556)
        at com.codefutures.common.messaging.transport.nio.NioServer.access$200(NioServer.java:25)
        at com.codefutures.common.messaging.transport.nio.NioServer$2.run(NioServer.java:534)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

由于dbshards.com产品拒绝它们,Ruby On Rails中是否有办法完全关闭会话变量?

0 个答案:

没有答案