Skip to content

ddl lock can't be released when server connection is abnormally closed #1168

@PanternBao

Description

@PanternBao
  • dble version:
    2.19.03.0 or earlier
  • preconditions :
    no
  • configs:

schema.xml

<dble:schema xmlns:dble="http://dble.cloud/">
    <schema name="testdb" dataNode="dn1">
        <table name="test" dataNode="dn1,dn2,dn3,dn4" rule="sharding-by-mod" type="default"/>
    </schema>

    <dataNode name="dn1" dataHost="localhost1" database="db1"/>
    <dataNode name="dn2" dataHost="localhost1" database="db2"/>
    <dataNode name="dn3" dataHost="localhost2" database="db1"/>
    <dataNode name="dn4" dataHost="localhost2" database="db2"/>

    <dataHost name="localhost1" maxCon="1000" minCon="10" balance="0" switchType="1" slaveThreshold="100">
        <heartbeat>show slave status</heartbeat>
        <!-- can have multi write hosts -->
        <writeHost host="hostM1" url="localhost:3306" user="root"
                   password="123456"/>
    </dataHost>

    <dataHost name="localhost2" maxCon="1000" minCon="10" balance="0" switchType="1" slaveThreshold="100">
        <heartbeat>show slave status</heartbeat>
        <writeHost host="hostS1" url="localhost:3307" user="root"
                   password="123456"/>
    </dataHost>
</dble:schema>

rule.xml

<dble:rule xmlns:dble="http://dble.cloud/">
    <tableRule name="sharding-by-mod">
        <rule>
            <columns>id</columns>
            <algorithm>hashmod</algorithm>
        </rule>
    </tableRule> 
    <function name="hashmod" class="Hash">
        <property name="partitionCount">4</property>
        <property name="partitionLength">1</property>
    </function>
</dble:rule>

server.xml

default
  • steps:
    step1. debug in MultiNodeDdlHandler#rowEofResponse() clearIfSessionClosed(session)
    step2. execute jdbc code as follows
public static void testDdl() {
        Connection conn = null;
        Statement stmt = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn =  DriverManager.getConnection("jdbc:mysql://localhost:8066/testdb", "root", "123456");
            stmt = conn.createStatement();
            boolean rs = stmt.execute("create table loaddata (id int)");

        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException ce) {
            ce.printStackTrace();
        } finally {
            try {
                if (stmt != null) {
                    stmt.close();
                }
                if (conn != null) {
                    conn.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

step 3. stop test code

  • expect result:
    1. connect dble and execute ddl normally
  • real result:
    1. ERROR 4006 (HY000): SCHEMA[testdb], TABLE[test] is doing DDL
  • supplements:
    1.

/label ~BUG

Metadata

Metadata

Assignees

Labels

Priority/Highexpect fix as quickly as possibleresolveproblem has been fixed by developer

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions