Skip to content

Transaction support #975

Closed
Closed
@zhicwu

Description

Server

  • Transaction ID: Tuple(snapshot_version UInt64, local_txid_counter UInt64, host_id UUID)
  • functions: transactionID(), transactionLatestSnapshot(), transactionOldestSnapshot()
  • settings: throw_on_unsupported_query_inside_transaction, wait_changes_become_visible_after_commit_mode, implicit_transaction
  • statements: begin transaction, commit, rollback, set transaction snapshot <snapshot id>, kill transaction where tid=<transaction id>

Java Client

  • new client option transaction_timeout, defaults to session_timeout
  • add ClickHouseTransaction with methods for begin/commit/rollback transaction and snapshot
  • add ClickHouseRequestManager for generating query id and session id as well as transaction creation
  • enhance ClickHouseRequest by adding methods getTransaction and setTransaction - multiple requests can take part in one transaction
  • throw ClickHouseTransactionException for Code: 649. DB::Exception: Cannot execute query because current transaction failed. Expecting ROLLBACK statement. (INVALID_TRANSACTION) - server will rollback automatically but still needs client to explicitly to acknowledge that by issue rollback(using connection.rollback())
  • always create new session when begin transaction and enforce session_check until transaction completed
  • consider transaction in retry and failover(avoid node switching)

JDBC Driver

  • new JDBC option transactionSupport (defaults to false)
  • use implicit_transaction in auto commit mode, fallback to TCL when it's not supported
  • replace FakeTransaction when transaction support is enabled
  • change default transaction isolation level to repeatable-read(why?)
  • parse TCL to maintain transaction consistency between server and client in 0.3.3?
  • update SIT base classes in 0.3.3 to use docker-compose instead of standalone container and then enable tests for HA and TX in CI

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions