ACID Transactions #
Proxima supports distributed ACID transactions with serializable isolation level based on the Proxima Transactions design document.
Transaction Modes #
Each attribute in your model can declare a transactional mode corresponding to
TransactionMode:
| Mode | Scope |
|---|---|
none (default) | No transactional guarantees. |
attribute | Colliding writes within the same attribute are rejected. |
key | Transactions scoped to a single entity key of a single entity. |
entity | Transactions spanning multiple keys of a single entity type. |
all | Global ACID consistency across arbitrary keys and entities. |
Current Server Support:
TransactionManagerServercurrently supportsallandnone(TransactionMode.ALLandTransactionMode.NONE). Declaring other modes will throwUnsupportedOperationExceptionwhen startingTransactionManagerServer.
Configuring Transaction Support #
Enabling transactions requires:
- Marking transactional attributes with
transactional: alland associating them with transaction manager family/families viamanager. - Defining commit-log attribute families for the built-in system entity
_transaction(request.*,response.*,state, andcommit). - Ensuring a transaction serializer scheme is on the classpath (
proxima-scheme-protois recommended;java:fromproxima-corealso provides a fallback, or you can configuretransactions.scheme-providerexplicitly). - If persisting transactional attributes to HBase or Bigtable, append
?v=2to the storage URI so the storage preservesStreamElement.getSequentialId().
Minimal Single-Topic Manager Configuration #
entities {
gateway {
attributes {
status {
scheme: bytes
transactional: all
manager: gateway-transaction-commit-log
}
intField {
scheme: integer
transactional: all
manager: gateway-transaction-commit-log
}
"device.*" {
scheme: bytes
transactional: all
manager: gateway-transaction-commit-log
}
}
}
}
attributeFamilies {
gateway-transaction-commit-log {
entity: _transaction
attributes: [ "request.*", "response.*", "state" ]
storage: "kafka://kafka-broker:9092/gateway-transactions"
type: primary
access: [ commit-log, state-commit-log, cached-view ]
}
transactions-commit {
entity: _transaction
attributes: [ "commit" ]
storage: "kafka://kafka-broker:9092/transactions-commit"
type: primary
access: commit-log
}
}
Important: The attribute family holding
_transaction.statemust include[ commit-log, state-commit-log, cached-view ]access (backed by a compacted Kafka topic in production), and there must be a primarycommit-logfamily for_transaction.commit.
Scalable Split-Topic Manager Configuration #
For production workloads, split request.*, response.*, and state into dedicated topics so the compacted state topic stays small while high-volume request.* and response.* topics use short retention:
entities {
gateway {
attributes {
"user.*" {
scheme: bytes
transactional: all
manager: [
all-transaction-request,
all-transaction-response,
all-transaction-state
]
}
}
}
}
attributeFamilies {
all-transaction-request {
entity: _transaction
attributes: [ "request.*" ]
storage: "kafka://kafka-broker:9092/tx-request"
}
all-transaction-response {
entity: _transaction
attributes: [ "response.*" ]
storage: "kafka://kafka-broker:9092/tx-response"
}
all-transaction-state {
entity: _transaction
attributes: [ "state" ]
storage: "kafka://kafka-broker:9092/tx-state"
# access defaults automatically to [ commit-log, state-commit-log, cached-view ]
}
transactions-commit {
entity: _transaction
attributes: [ "commit" ]
storage: "kafka://kafka-broker:9092/tx-commit"
type: primary
access: commit-log
}
}
Using the Transaction API #
Transactions are supported through
DirectDataOperator (and transitively via
ProximaIO.write and
gRPC RetrieveService/IngestService).
The API centers on
TransactionalOnlineAttributeWriter.Transaction. Because Proxima uses optimistic concurrency control with serializable conflict detection, execute transactional logic inside a retry loop that restarts on TransactionRejectedException:
Repository repo =
Repository.ofTest(
ConfigFactory.parseResources("test-transactions.conf").resolve());
DirectDataOperator direct = repo.getOrCreateOperator(DirectDataOperator.class);
EntityDescriptor gateway = repo.getEntity("gateway");
Regular<Integer> intField = Regular.of(gateway, gateway.getAttribute("intField"));
Wildcard<?> device = Wildcard.of(gateway, gateway.getAttribute("device.*"));
OnlineAttributeWriter writer = direct.getWriter(intField).orElseThrow();
RandomAccessReader reader = direct.getRandomAccess(device).orElseThrow();
Preconditions.checkState(writer.isTransactional());
String gatewayId = "gw1";
while (true) {
try (Transaction transaction = writer.transactional().begin()) {
// 1. Read inputs participating in the transaction
List<KeyValue<?>> kvs = new ArrayList<>();
reader.scanWildcard(gatewayId, device, kvs::add);
// 2. Register all read inputs with the transaction manager
transaction.update(
KeyAttributes.ofWildcardQueryElements(gateway, gatewayId, device, kvs));
// 3. Prepare transactional outputs (sequentialId is assigned by the coordinator)
StreamElement upsert = intField.upsert(
gatewayId, 1L, kvs.size());
// 4. Commit and await confirmation
BlockingQueue<Pair<Boolean, Throwable>> result = new ArrayBlockingQueue<>(1);
transaction.commitWrite(
Collections.singletonList(upsert),
(succ, exc) -> result.offer(Pair.of(succ, exc)));
// Synchronous wait shown for simplicity; prefer async callbacks in production
Pair<Boolean, Throwable> taken = ExceptionUtils.uncheckedFactory(result::take);
if (!taken.getFirst()) {
if (taken.getSecond() instanceof TransactionRejectedException) {
// Optimistic conflict detected: re-read state and retry
continue;
}
throw new IllegalStateException("Transaction failed", taken.getSecond());
}
// Committed successfully
break;
}
}
For transactions spanning multiple attributes that do not share a single primary writer, obtain a global transactional writer via direct.getGlobalTransactionWriter(). When reading transactional attributes from a CachedView, direct.getCachedView(...) automatically wraps the view in a TransactionalCachedView.
Transaction Workflow & Architecture #

Transaction coordination relies on four commit logs:
request.*— client transaction lifecycle messages (OPEN,UPDATE,COMMIT,ROLLBACK)response.*— coordinator acknowledgements and conflict rejections routed back to clientsstate— compacted log of active/committed transaction states and latest sequential IDs per key-attributecommit— atomic commit log carrying accepted outputs, state transitions, and client responses
Proxima guarantees serializable isolation by assigning each committed transaction a monotonically increasing sequentialId, which is stamped onto every output StreamElement written by that transaction. Whenever a client calls transaction.update(...) with the KeyAttributes (and observed sequential IDs) it read and subsequently calls transaction.commitWrite(...), the transaction manager validates that none of the input keys were modified by a newer committed transaction:
- On first
update(...)(orcommitWrite(...)),TransactionalOnlineAttributeWritersends aRequestto_transaction.request.*. - The transaction manager checks conflicts against its in-memory/cached
stateand emits aCommitto_transaction.commit. - The
Replication controller consumes
_transaction.commitvia the built-inTransactionCommitTransformationand atomically fans out:- the accepted data writes to target entity primary commit logs,
- updated transaction state records to
_transaction.state, and Responsemessages to_transaction.response.*notifying the waiting client.
- If a conflict occurred, the client’s callback receives
TransactionRejectedExceptionso the application can safely retry.
Runtime Components #
Running ACID transactions requires two runtime services:
- Transaction Manager Server (
cz.o2.proxima:proxima-direct-transaction-manager, main classTransactionManagerServer):- Consumes
_transaction.request.*and writes decisions to_transaction.commit. - Runs in active/standby mode (multiple instances can be deployed for automatic failover, with one active leader processing requests at a time).
java -cp my-proxima-tx-manager.jar \ cz.o2.proxima.direct.transaction.manager.TransactionManagerServer - Consumes
- Replication Controller (
cz.o2.proxima:proxima-ingest-server-grpc, main classReplicationController):- Runs
TransactionCommitTransformationto apply committed transactions to target primary families,_transaction.state, and_transaction.response.*, and replicates updates onward to all replica storages.
- Runs