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

Oracle增加表字段导致“违反协议”异常 #1598

Open
kajelas opened this issue Feb 6, 2017 · 6 comments
Open

Oracle增加表字段导致“违反协议”异常 #1598

kajelas opened this issue Feb 6, 2017 · 6 comments
Labels
Milestone

Comments

@kajelas
Copy link

kajelas commented Feb 6, 2017

按照如下步骤可以重现BUG:

  1. 启动开启了druid ps cache的应用
  2. 在应用中执行一条关于某张表(表中有数据)的SQL语句(比如select * from A)
  3. 在这张表中增加一个字段
  4. 再执行步骤2中的SQL语句,就会出现"ora-17401:违反协议"异常。
  5. 重启应用后,不再出现异常(关闭ps cache也不会出现该异常)

该BUG在1.0.25、1.0.27、1.0.28版本中均有出现。其中,1.0.25版本是必现的,1.0.27和1.0.28因为会抛弃出错的PreparedStatement,所以不是必现的。但是多次、有间隔地重复步骤4,还是会出现该异常。

虽然OracleExceptionSorter类中将ora-17401定义成了fatal类异常,但似乎连接池并没有正确地抛弃出错的连接。

更多信息请参考#1498 #1516 #1557

@kajelas
Copy link
Author

kajelas commented Feb 7, 2017

这个问题已经查清,是我们给Druid连接池设置的driverClassName写的有问题,应该是oracle.jdbc.OracleDriver,我们写成了oracle.jdbc.driver.OracleDriver,这就导致Druid的ExceptionSorter没有正常启动,所以出现"ora-17401:违反协议"异常之后,连接没有被正确地抛弃。

但是不是可以在初始化ExceptionSorter和ValidConnectionChecker的时候把oracle.jdbc.driver.OracleDriver这种driver的判断也给加上,来加强一些兼容性:

else if (realDriverClassName.equals(JdbcConstants.ORACLE_DRIVER)) {
            this.exceptionSorter = new OracleExceptionSorter();
}

因为可能很多老应用都写的是oracle.jdbc.driver.OracleDriver,而且这种写法应用也能正常使用,只是oracle 9i以后把oracle.jdbc.driver.OracleDriver标记成了Deprecated。

@wenshao wenshao added this to the 1.0.29 milestone Feb 11, 2017
wenshao added a commit that referenced this issue Feb 11, 2017
@wenshao
Copy link
Member

wenshao commented Feb 11, 2017

谢谢反馈,问题已经修正,将会在下一个版本1.0.29中带上

@kajelas
Copy link
Author

kajelas commented Feb 24, 2017

修正里面漏了ValidConnectionChecker的初始化:

    private void initValidConnectionChecker() {
        String realDriverClassName = driver.getClass().getName();
        if (realDriverClassName.equals(JdbcConstants.MYSQL_DRIVER) //
            || realDriverClassName.equals(JdbcConstants.MYSQL_DRIVER_6)) {
            this.validConnectionChecker = new MySqlValidConnectionChecker();
        } else if (realDriverClassName.equals(JdbcConstants.ORACLE_DRIVER
                  || realDriverClassName.equals(JdbcConstants.ORACLE_DRIVER2)) {
            this.validConnectionChecker = new OracleValidConnectionChecker();
        } else if (realDriverClassName.equals(JdbcConstants.SQL_SERVER_DRIVER)
                   || realDriverClassName.equals(JdbcConstants.SQL_SERVER_DRIVER_SQLJDBC4)
                   || realDriverClassName.equals(JdbcConstants.SQL_SERVER_DRIVER_JTDS)) {
            this.validConnectionChecker = new MSSQLValidConnectionChecker();
        } else if (realDriverClassName.equals(JdbcConstants.POSTGRESQL_DRIVER)) {
            this.validConnectionChecker = new PGValidConnectionChecker();
        }
    }

@qquanm
Copy link

qquanm commented May 11, 2017

还是没有解决,我们更新成1.29并且把驱动名称改成oracle.jdbc.OracleDriver,仍然报这个异常

@wenshao wenshao added the Bug label Oct 3, 2017
@qquanm
Copy link

qquanm commented Nov 14, 2017

这个问题有修复吗,我们目前采用了很恶心的方式解决的 @wenshao http://blog.csdn.net/zl18310999566/article/details/71678361?locationNum=13&fps=1

@killersteps
Copy link

两年多了,仍然没有解决,仍然需要爬坑。

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

No branches or pull requests

4 participants