Skip to content

Session is completely corrupted by the failed statement in a non-autocommit transaction #23246

@hantangwangd

Description

@hantangwangd

Sometimes we want to manually start a transaction and execute some statements in it, then finally uniformly commit the transaction.

However, if any one of the statements failed when executing, it would cause a completely corruption of current session. That is, we can't execute any SQLs any more even including rollback because of the exception as follows:

Current transaction is aborted, commands ignored until end of transaction block

Currently, we can do noting but quit and reconnect to use a new session.

Expected Behavior

Enable to successfully execute rollback to end the transaction block

Current Behavior

Execution of rollback fails because of the current transaction being aborted

Possible Solution

Do not check transaction's state when executing rollback.

Steps to Reproduce

  1. Open a CLI console, and use hive connector, for example:
use hive.default;
  1. Execute the following statements:
set role admin;        // To make sure the problem always shows up

create table test_non_autocommit_table (a bigint, b double, c varchar) with(partitioned_by = array['c']);

start transaction;

insert into test_non_autocommit_table values(1, 1.1, '1001'), (2, 1.2, '1002');

// would fail because inserting into the same partition in the same transaction
insert into test_non_autocommit_table values(3, 1.3, '1002');
  1. After the fail insertion, now we can not execute any sql because of Current transaction is aborted ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions