blob: 28ff4334364ed18263c389691c1391a5a7173e7a [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<link rel="canonical" href="https://ignite.apache.org/releases/latest/dotnetdoc/api/Apache.Ignite.Core.Transactions.html" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Namespace Apache.Ignite.Core.Transactions
| Apache Ignite.NET </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Namespace Apache.Ignite.Core.Transactions
| Apache Ignite.NET ">
<meta name="generator" content="docfx 2.24.0.0">
<link rel="shortcut icon" href="../images/favicon.ico">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
<link rel="stylesheet" href="../styles/docfx.css">
<link rel="stylesheet" href="../styles/main.css">
<meta property="docfx:navrel" content="../toc.html">
<meta property="docfx:tocrel" content="toc.html">
<meta property="docfx:rel" content="../">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-61232409-1', 'auto');
ga('send', 'pageview');
</script></head>
<body data-spy="scroll" data-target="#affix">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../images/logo_ignite_32_32.png" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items"></div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="Apache.Ignite.Core.Transactions">
<h1 id="Apache_Ignite_Core_Transactions" data-uid="Apache.Ignite.Core.Transactions" class="text-break">Namespace Apache.Ignite.Core.Transactions
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>
<div class="markdown level0 remarks"></div>
<h3 id="classes">Classes
</h3>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionConfiguration.html">TransactionConfiguration</a></h4>
<section><p>Transactions configuration.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionDeadlockException.html">TransactionDeadlockException</a></h4>
<section><p>Indicates a deadlock within Ignite transaction.
<p>
This exception can be thrown from any cache method that modifies or reads data within a transaction
with timeout (see
<a class="xref" href="Apache.Ignite.Core.Transactions.ITransactions.html#Apache_Ignite_Core_Transactions_ITransactions_TxStart_Apache_Ignite_Core_Transactions_TransactionConcurrency_Apache_Ignite_Core_Transactions_TransactionIsolation_System_TimeSpan_System_Int32_">TxStart(TransactionConcurrency, TransactionIsolation, TimeSpan, Int32)</a> overload).</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionHeuristicException.html">TransactionHeuristicException</a></h4>
<section><p>Exception thrown whenever Ignite transaction enters an unknown state.
This exception is usually thrown whenever commit partially succeeds.
Cache will still resolve this situation automatically to ensure data
integrity, by invalidating all values participating in this transaction
on remote nodes. </p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionOptimisticException.html">TransactionOptimisticException</a></h4>
<section><p>Exception thrown whenever Ignite transactions fail optimistically. </p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionRollbackException.html">TransactionRollbackException</a></h4>
<section><p>Exception thrown whenever Ignite transactions has been automatically rolled back. </p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionTimeoutException.html">TransactionTimeoutException</a></h4>
<section><p>Exception thrown whenever Ignite transactions time out. </p>
</section>
<h3 id="interfaces">Interfaces
</h3>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.ITransaction.html">ITransaction</a></h4>
<section><p>Grid cache transaction.
<p>
Cache transactions support the following isolation levels:
<ul><li><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionIsolation.html#Apache_Ignite_Core_Transactions_TransactionIsolation_ReadCommitted">ReadCommitted</a> isolation level
means that always a committed value will be provided for read operations. With this isolation
level values are always read from cache global memory or persistent store every time a value
is accessed. In other words, if the same key is accessed more than once within the same transaction,
it may have different value every time since global cache memory may be updated concurrently by
other threads.</li><li><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionIsolation.html#Apache_Ignite_Core_Transactions_TransactionIsolation_RepeatableRead">RepeatableRead</a> isolation level
means that if a value was read once within transaction, then all consecutive reads will provide
the same in-transaction value. With this isolation level accessed values are stored within
in-transaction memory, so consecutive access to the same key within the same transaction will always
return the value that was previously read or updated within this transaction. If concurrency is
<a class="xref" href="Apache.Ignite.Core.Transactions.TransactionConcurrency.html#Apache_Ignite_Core_Transactions_TransactionConcurrency_Pessimistic">Pessimistic</a>, then a lock on the key will be
acquired prior to accessing the value.</li><li><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionIsolation.html#Apache_Ignite_Core_Transactions_TransactionIsolation_Serializable">Serializable</a> isolation level means
that all transactions occur in a completely isolated fashion, as if all transactions in the system
had executed serially, one after the other. Read access with this level happens the same way as with
<a class="xref" href="Apache.Ignite.Core.Transactions.TransactionIsolation.html#Apache_Ignite_Core_Transactions_TransactionIsolation_RepeatableRead">RepeatableRead</a> level. However, in
<a class="xref" href="Apache.Ignite.Core.Transactions.TransactionConcurrency.html#Apache_Ignite_Core_Transactions_TransactionConcurrency_Optimistic">Optimistic</a> mode, if some transactions cannot be
serially isolated from each other, then one winner will be picked and the other transactions in
conflict will result in <code>TransactionOptimisticException</code> being thrown on Java side.</li></ul>
Cache transactions support the following concurrency models:
<ul><li><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionConcurrency.html#Apache_Ignite_Core_Transactions_TransactionConcurrency_Optimistic">Optimistic</a> - in this mode all cache
operations
are not distributed to other nodes until <a class="xref" href="Apache.Ignite.Core.Transactions.ITransaction.html#Apache_Ignite_Core_Transactions_ITransaction_Commit">Commit()</a>.
In this mode one <code>PREPARE</code> message will
be sent to participating cache nodes to start acquiring per-transaction locks, and once all nodes
reply <code>OK</code> (i.e. <code>Phase 1</code> completes successfully), a one-way <code>COMMIT</code> message is sent
without waiting for reply. If it is necessary to know whenever remote nodes have committed as well,
synchronous commit or synchronous rollback should be enabled via
<code>CacheConfiguration.setWriteSynchronizationMode</code>.
<p>
Note that in this mode, optimistic failures are only possible in conjunction with
<a class="xref" href="Apache.Ignite.Core.Transactions.TransactionIsolation.html#Apache_Ignite_Core_Transactions_TransactionIsolation_Serializable">Serializable</a> isolation level. In all other cases,
optimistic transactions will never fail optimistically and will always be identically ordered on all
participating Ignite nodes.</li><li><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionConcurrency.html#Apache_Ignite_Core_Transactions_TransactionConcurrency_Pessimistic">Pessimistic</a> - in this mode a lock is
acquired on all cache operations with exception of read operations in
<a class="xref" href="Apache.Ignite.Core.Transactions.TransactionIsolation.html#Apache_Ignite_Core_Transactions_TransactionIsolation_ReadCommitted">ReadCommitted</a> mode. All optional filters passed
into cache operations will be evaluated after successful lock acquisition. Whenever
<a class="xref" href="Apache.Ignite.Core.Transactions.ITransaction.html#Apache_Ignite_Core_Transactions_ITransaction_Commit">Commit()</a> is called, a single one-way <code>COMMIT</code>
message is sent to participating cache nodes without waiting for reply. Note that there is no reason
for distributed <code>PREPARE</code> step, as all locks have been already acquired. Just like with
optimistic mode, it is possible to configure synchronous commit or rollback and wait till
transaction commits on all participating remote nodes.</li></ul>
<p>
In addition to standard <code>CacheAtomicityMode.TRANSACTIONAL</code> behavior, Ignite also supports
a lighter <code>CacheAtomicityMode.ATOMIC</code> mode as well. In this mode distributed transactions
and distributed locking are not supported. Disabling transactions and locking allows to achieve much higher
performance and throughput ratios. It is recommended that <code>CacheAtomicityMode.TRANSACTIONAL</code> mode
is used whenever full <code>ACID</code>-compliant transactions are not needed.
<example>
You can use cache transactions as follows:<p>
<pre><code>ICacheTx tx = cache.TxStart();
try
{
int v1 = cache&lt;string, int>.Get(&quot;k1&quot;);
// Check if v1 satisfies some condition before doing a put.
if (v1 > 0)
cache.Put&lt;string, int>(&quot;k1&quot;, 2);
cache.Removex(&quot;k2);
// Commit the transaction.
tx.Commit();
}
finally
{
tx.Dispose();
}</code></pre>
<p></example></p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.ITransactionCollection.html">ITransactionCollection</a></h4>
<section><p>Disposable readonly collection of <a class="xref" href="Apache.Ignite.Core.Transactions.ITransaction.html">ITransaction</a></p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.ITransactionMetrics.html">ITransactionMetrics</a></h4>
<section><p>Transaction metrics, shared across all caches.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.ITransactions.html">ITransactions</a></h4>
<section><p>Transactions facade.
<p>
All members are thread-safe and may be used concurrently from multiple threads.</p>
</section>
<h3 id="enums">Enums
</h3>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionConcurrency.html">TransactionConcurrency</a></h4>
<section><p>Transaction concurrency control. See <a class="xref" href="Apache.Ignite.Core.Transactions.ITransaction.html">ITransaction</a> for more
information on transaction concurrency controls.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionIsolation.html">TransactionIsolation</a></h4>
<section><p>Defines different cache transaction isolation levels. See <a class="xref" href="Apache.Ignite.Core.Transactions.ITransaction.html">ITransaction</a>
documentation for more information about cache transaction isolation levels.</p>
</section>
<h4><a class="xref" href="Apache.Ignite.Core.Transactions.TransactionState.html">TransactionState</a></h4>
<section><p>Cache transaction state.</p>
</section>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
© 2015 - 2019 The Apache Software Foundation
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../styles/docfx.js"></script>
<script type="text/javascript" src="../styles/main.js"></script>
</body>
</html>