You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

IDIEP-34
Author
Sponsor
Created

 

Status
DRAFT


Motivation

Currently transactions are not supported by thin client protocol. 

Description

There are changes needed for protocol, server side, and client side to support transactions.

Protocol changes

Add new operations to the thin client protocol:

NameCodeDescription
OP_TX_START4000Start a new transaction
OP_TX_END4001End the transaction

OP_TX_START message format

Request
byte

Concurrency control:

0 - OPTIMISTIC

1 - PESSIMISTIC

-1 - use server's default value

byte

Isolation level:

0 - READ_COMMITTED

1 - REPEATABLE_READ

2 - SERIALIZABLE

-1 - use server's default value

longTimeout (-1 - use server's default value)
stringlabel
Response

intUnique per client connection transaction id. This id should be returned as parameter with OP_TX_END message.

OP_TX_END message format

Request
int

Transaction id.

bool

Commit flag.


Empty response.

Cache operations

We need to add a new field to requests header of all cache data manipulation operations (opcodes 1000-1020, 2000, 2002, 2004) to bind these operations with the transaction.

We also can remove deprecated "flag" field in this protocol version. "Flag" field is only used by OP_QUERY_SCAN operation. So, we need to add a new field "keepBinary" to OP_QUERY_SCAN request.

Proposed changes to cache operations request header format:

TypeDescription
intLength of payload
shortOperation code
longRequest id
intCache id
byteflagremoved
intTransaction id (0 if there is no explicitly started transaction)added

Proposed changes to OP_QUERY_SCAN request format:

TypeDescription
HeaderCache operation request header
boolKeep binaryadded
Data ObjectFilter object. Can be null if you are not going to filter data on the cluster. The filter class has to be added to the classpath of the server nodes
byteFilter platform:
JAVA = 1
DOTNET = 2
CPP = 3

intCursor page size
intNumber of partitions to query (negative to query entire cache)
boolLocal flag - whether this query should be executed on local node only

Server-side changes

On the server side, we need to have the ability to decouple transactions from threads. We can do this by using transaction suspend/resume methods. Suspend/resume methods are only implemented for optimistic transactions now, so we need to implement this mechanism for pessimistic transactions first.

Using this approach there is no need to start any new thread to serve the transaction. All transaction control operations and all cache operations within transactions will be served by existing "client-connector" threads.

When the client sends OP_TX_START request, a new transaction is starting in a suspended state.

When the client performs a cache operation within a transaction, thread served this request resumes the transaction, processes cache operation and suspends the transaction again.

When the client sends OP_TX_END request, thread served this request resumes the transaction and commit or rollback it.

Client-side changes

The client must bind transaction and all cache operations which was made within this explicitly started transaction. We can implement transaction per thread approach on the thin client side as implemented now for the thick client. In this case, each transaction on the thin client side will be bound to a thread started this transaction. And each cache operation performed by this thread will be bound to the same transaction until the transaction is completed.

Also, the client implementation must review the logic of failover, since we can't silently change servers in case of connection error in the middle of the transaction.

Proposed new interfaces for java thin client:

ClientTransactions
public interface ClientTransactions {
    public ClientTransaction txStart();
    public ClientTransaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation);
    public ClientTransaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout);
    public ClientTransactions withLabel(String lb);
}


ClientTransaction
public interface ClientTransaction extends AutoCloseable {
    public void commit();
    public void rollback();
    public void close();
}


Risks and Assumptions

//

Discussion Links

http://apache-ignite-developers.2346864.n4.nabble.com/Thin-client-transactions-support-td27761.html

Reference Links

// Links to various reference documents, if applicable.

Tickets

key summary type created updated due assignee reporter priority status resolution

JQL and issue key arguments for this macro require at least one Jira application link to be configured

  • No labels