ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Antonov (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (IGNITE-11795) JDBC thin datastreamer don't throws exception is case of problems on closing streamer.
Date Wed, 24 Apr 2019 11:23:00 GMT

     [ https://issues.apache.org/jira/browse/IGNITE-11795?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sergey Antonov updated IGNITE-11795:
------------------------------------
    Description: 
Now from code we can't detect problems, If some errors occurs in closing jdbc thin datastreamer.
Now we could detect it in logs only. The main reason of this is using {{U.close()}} for streamers
in {{SqlClientContext#disableStreaming()}}. 

You could add test to {{JdbcThinStreamingAbstractSelfTest}} and reproduce problem.
{code:java}
    /**
     * @throws Exception if failed.
     */
    @Test
    public void testStreamedInsertFailsOnReadOnlyMode() throws Exception {
        for (Ignite grid : G.allGrids())
            ((IgniteEx) grid).context().cache().context().readOnlyMode(true);

        try {
            boolean failed = false;

            try (Connection ordinalCon = createOrdinaryConnection();
                 Statement selectStmt = ordinalCon.createStatement()
            ) {
                try (ResultSet rs = selectStmt.executeQuery("select count(*) from PUBLIC.Person"))
{
                    assertTrue(rs.next());

                    assertEquals(0, rs.getLong(1));
                }

                try (Connection conn = createStreamedConnection(true)) {
                    try (PreparedStatement stmt =
                             conn.prepareStatement("insert into PUBLIC.Person(\"id\", \"name\")
values (?, ?)")
                    ) {
                        for (int i = 1; i <= 2; i++) {
                            stmt.setInt(1, i);
                            stmt.setString(2, nameForId(i));

                            stmt.executeUpdate();
                        }
                    }
                }
                catch (Exception e) {
                    log.error("Insert failed", e);

                    failed = true;
                }

                try (ResultSet rs = selectStmt.executeQuery("select count(*) from PUBLIC.Person"))
{
                    assertTrue(rs.next());

                    assertEquals("Insert should be failed!", 0, rs.getLong(1));
                }
            }

            assertTrue("Insert should be failed!", failed);
        }
        finally {
            for (Ignite grid : G.allGrids())
                ((IgniteEx) grid).context().cache().context().readOnlyMode(false);
        }
    }
{code}

Don't forget remove {{@Ignore}} annotation from {{JdbcThinStreamingAbstractSelfTest#testStreamedInsertFailsOnReadOnlyMode()}}
test!



  was:
Now from code we can't detect problems, If some errors occurs in closing jdbc thin datastreamer.
Now we could detect it in logs only. The main reason of this is using {{U.close()}} for streamers
in {{SqlClientContext#disableStreaming()}}. 

You could add test to {{JdbcThinStreamingAbstractSelfTest}} and reproduce problem.
{code:java}
    /**
     * @throws Exception if failed.
     */
    @Test
    public void testStreamedInsertFailsOnReadOnlyMode() throws Exception {
        for (Ignite grid : G.allGrids())
            ((IgniteEx) grid).context().cache().context().readOnlyMode(true);

        try {
            boolean failed = false;

            try (Connection ordinalCon = createOrdinaryConnection();
                 Statement selectStmt = ordinalCon.createStatement()
            ) {
                try (ResultSet rs = selectStmt.executeQuery("select count(*) from PUBLIC.Person"))
{
                    assertTrue(rs.next());

                    assertEquals(0, rs.getLong(1));
                }

                try (Connection conn = createStreamedConnection(true)) {
                    try (PreparedStatement stmt =
                             conn.prepareStatement("insert into PUBLIC.Person(\"id\", \"name\")
values (?, ?)")
                    ) {
                        for (int i = 1; i <= 2; i++) {
                            stmt.setInt(1, i);
                            stmt.setString(2, nameForId(i));

                            stmt.executeUpdate();
                        }
                    }
                }
                catch (Exception e) {
                    log.error("Insert failed", e);

                    failed = true;
                }

                try (ResultSet rs = selectStmt.executeQuery("select count(*) from PUBLIC.Person"))
{
                    assertTrue(rs.next());

                    assertEquals("Insert should be failed!", 0, rs.getLong(1));
                }
            }

            assertTrue("Insert should be failed!", failed);
        }
        finally {
            for (Ignite grid : G.allGrids())
                ((IgniteEx) grid).context().cache().context().readOnlyMode(false);
        }
    }
{code}




> JDBC thin datastreamer don't throws exception is case of problems on closing streamer.
> --------------------------------------------------------------------------------------
>
>                 Key: IGNITE-11795
>                 URL: https://issues.apache.org/jira/browse/IGNITE-11795
>             Project: Ignite
>          Issue Type: Bug
>          Components: jdbc, sql, thin client
>            Reporter: Sergey Antonov
>            Priority: Major
>             Fix For: 2.8
>
>
> Now from code we can't detect problems, If some errors occurs in closing jdbc thin datastreamer.
Now we could detect it in logs only. The main reason of this is using {{U.close()}} for streamers
in {{SqlClientContext#disableStreaming()}}. 
> You could add test to {{JdbcThinStreamingAbstractSelfTest}} and reproduce problem.
> {code:java}
>     /**
>      * @throws Exception if failed.
>      */
>     @Test
>     public void testStreamedInsertFailsOnReadOnlyMode() throws Exception {
>         for (Ignite grid : G.allGrids())
>             ((IgniteEx) grid).context().cache().context().readOnlyMode(true);
>         try {
>             boolean failed = false;
>             try (Connection ordinalCon = createOrdinaryConnection();
>                  Statement selectStmt = ordinalCon.createStatement()
>             ) {
>                 try (ResultSet rs = selectStmt.executeQuery("select count(*) from PUBLIC.Person"))
{
>                     assertTrue(rs.next());
>                     assertEquals(0, rs.getLong(1));
>                 }
>                 try (Connection conn = createStreamedConnection(true)) {
>                     try (PreparedStatement stmt =
>                              conn.prepareStatement("insert into PUBLIC.Person(\"id\",
\"name\") values (?, ?)")
>                     ) {
>                         for (int i = 1; i <= 2; i++) {
>                             stmt.setInt(1, i);
>                             stmt.setString(2, nameForId(i));
>                             stmt.executeUpdate();
>                         }
>                     }
>                 }
>                 catch (Exception e) {
>                     log.error("Insert failed", e);
>                     failed = true;
>                 }
>                 try (ResultSet rs = selectStmt.executeQuery("select count(*) from PUBLIC.Person"))
{
>                     assertTrue(rs.next());
>                     assertEquals("Insert should be failed!", 0, rs.getLong(1));
>                 }
>             }
>             assertTrue("Insert should be failed!", failed);
>         }
>         finally {
>             for (Ignite grid : G.allGrids())
>                 ((IgniteEx) grid).context().cache().context().readOnlyMode(false);
>         }
>     }
> {code}
> Don't forget remove {{@Ignore}} annotation from {{JdbcThinStreamingAbstractSelfTest#testStreamedInsertFailsOnReadOnlyMode()}}
test!



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message