You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2018/10/03 08:14:46 UTC
[1/4] ignite git commit: IGNITE-9390: MVCC: added new properties to
.NET IgniteConfiguration and CacheAtomicityMode. This closes #4887.
Repository: ignite
Updated Branches:
refs/heads/ignite-gg-14206 17f017896 -> ba13ed956
IGNITE-9390: MVCC: added new properties to .NET IgniteConfiguration and CacheAtomicityMode. This closes #4887.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/45721371
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/45721371
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/45721371
Branch: refs/heads/ignite-gg-14206
Commit: 457213713a442b734cddb59c1c8310fc6d9cd340
Parents: 96c271b
Author: devozerov <vo...@gridgain.com>
Authored: Tue Oct 2 14:27:39 2018 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Oct 2 14:27:39 2018 +0300
----------------------------------------------------------------------
.../apache/ignite/cache/CacheAtomicityMode.java | 10 +++--
.../configuration/IgniteConfiguration.java | 30 +++++++--------
.../utils/PlatformConfigurationUtils.java | 8 ++++
.../ApiParity/IgniteConfigurationParityTest.cs | 4 +-
.../Cache/CachePartitionedTest.cs | 37 ++++++++++++++++++
.../Config/full-config.xml | 2 +-
.../IgniteConfigurationSerializerTest.cs | 3 ++
.../IgniteConfigurationTest.cs | 7 ++++
.../Cache/Configuration/CacheAtomicityMode.cs | 30 ++++++++++++++-
.../Apache.Ignite.Core/IgniteConfiguration.cs | 40 ++++++++++++++++++++
.../IgniteConfigurationSection.xsd | 11 ++++++
.../Impl/Binary/BinaryReaderExtensions.cs | 8 ++++
.../Impl/Binary/BinaryWriterExtensions.cs | 16 +++++++-
13 files changed, 182 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicityMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicityMode.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicityMode.java
index 43c561c..5b101bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicityMode.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheAtomicityMode.java
@@ -38,6 +38,10 @@ public enum CacheAtomicityMode {
* <b>Note!</b> In this mode, transactional consistency is guaranteed for key-value API operations only.
* To enable ACID capabilities for SQL transactions, use the {@code TRANSACTIONAL_SNAPSHOT} mode.
* <p>
+ * <b>Note!</b> This atomicity mode is not compatible with the other modes within the same transaction.
+ * if a transaction is executed over multiple caches, all caches must have the same atomicity mode,
+ * either {@code TRANSACTIONAL_SNAPSHOT} or {@code TRANSACTIONAL}.
+ * <p>
* See {@link Transaction} for more information about transactions.
*/
TRANSACTIONAL,
@@ -109,9 +113,9 @@ public enum CacheAtomicityMode {
* by the coordinator. This snapshot ensures that the transaction works with a consistent database state
* during its execution period.
* <p>
- * Note! This atomicity mode is not compatible with the other modes within the same transaction.
- * If a transaction is executed over multiple caches, all caches must have the same mode,
- * either {@code TRANSACTIONAL_SNAPSHOT} or {@code TRANSACTIONAL}
+ * <b>Note!</b> This atomicity mode is not compatible with the other modes within the same transaction.
+ * If a transaction is executed over multiple caches, all caches must have the same atomicity mode,
+ * either {@code TRANSACTIONAL_SNAPSHOT} or {@code TRANSACTIONAL}.
* <p>
* See {@link Transaction} for more information about transactions.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 6a0c7cb..964c73b 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -214,11 +214,11 @@ public class IgniteConfiguration {
/** Default timeout after which long query warning will be printed. */
public static final long DFLT_LONG_QRY_WARN_TIMEOUT = 3000;
- /** Default size of MVCC vacuum thread pool. */
+ /** Default number of MVCC vacuum threads.. */
public static final int DFLT_MVCC_VACUUM_THREAD_CNT = 2;
- /** Default time interval between vacuum process runs (ms). */
- public static final int DFLT_MVCC_VACUUM_FREQUENCY = 5000;
+ /** Default time interval between MVCC vacuum runs in milliseconds. */
+ public static final long DFLT_MVCC_VACUUM_FREQUENCY = 5000;
/** Optional local Ignite instance name. */
private String igniteInstanceName;
@@ -496,8 +496,8 @@ public class IgniteConfiguration {
/** Size of MVCC vacuum thread pool. */
private int mvccVacuumThreadCnt = DFLT_MVCC_VACUUM_THREAD_CNT;
- /** Time interval between vacuum process runs (ms). */
- private int mvccVacuumFreq = DFLT_MVCC_VACUUM_FREQUENCY;
+ /** Time interval between vacuum runs (ms). */
+ private long mvccVacuumFreq = DFLT_MVCC_VACUUM_FREQUENCY;
/** User authentication enabled. */
private boolean authEnabled;
@@ -2998,18 +2998,18 @@ public class IgniteConfiguration {
}
/**
- * Returns number of MVCC vacuum cleanup threads.
+ * Returns number of MVCC vacuum threads.
*
- * @return Number of MVCC vacuum cleanup threads.
+ * @return Number of MVCC vacuum threads.
*/
public int getMvccVacuumThreadCount() {
return mvccVacuumThreadCnt;
}
/**
- * Sets number of MVCC vacuum cleanup threads.
+ * Sets number of MVCC vacuum threads.
*
- * @param mvccVacuumThreadCnt Number of MVCC vacuum cleanup threads.
+ * @param mvccVacuumThreadCnt Number of MVCC vacuum threads.
* @return {@code this} for chaining.
*/
public IgniteConfiguration setMvccVacuumThreadCount(int mvccVacuumThreadCnt) {
@@ -3019,21 +3019,21 @@ public class IgniteConfiguration {
}
/**
- * Returns time interval between vacuum runs.
+ * Returns time interval between MVCC vacuum runs in milliseconds.
*
- * @return Time interval between vacuum runs.
+ * @return Time interval between MVCC vacuum runs in milliseconds.
*/
- public int getMvccVacuumFrequency() {
+ public long getMvccVacuumFrequency() {
return mvccVacuumFreq;
}
/**
- * Sets time interval between vacuum runs.
+ * Sets time interval between MVCC vacuum runs in milliseconds.
*
- * @param mvccVacuumFreq Time interval between vacuum runs.
+ * @param mvccVacuumFreq Time interval between MVCC vacuum runs in milliseconds.
* @return {@code this} for chaining.
*/
- public IgniteConfiguration setMvccVacuumFrequency(int mvccVacuumFreq) {
+ public IgniteConfiguration setMvccVacuumFrequency(long mvccVacuumFreq) {
this.mvccVacuumFreq = mvccVacuumFreq;
return this;
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index cd67f15..8e66102 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -654,6 +654,10 @@ public class PlatformConfigurationUtils {
cfg.setActiveOnStart(in.readBoolean());
if (in.readBoolean())
cfg.setAuthenticationEnabled(in.readBoolean());
+ if (in.readBoolean())
+ cfg.setMvccVacuumFrequency(in.readLong());
+ if (in.readBoolean())
+ cfg.setMvccVacuumThreadCount(in.readInt());
int sqlSchemasCnt = in.readInt();
@@ -1201,6 +1205,10 @@ public class PlatformConfigurationUtils {
w.writeBoolean(cfg.isActiveOnStart());
w.writeBoolean(true);
w.writeBoolean(cfg.isAuthenticationEnabled());
+ w.writeBoolean(true);
+ w.writeLong(cfg.getMvccVacuumFrequency());
+ w.writeBoolean(true);
+ w.writeInt(cfg.getMvccVacuumThreadCount());
if (cfg.getSqlSchemas() == null)
w.writeInt(-1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs
index 5b4106a..1fd8e72 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs
@@ -80,9 +80,7 @@ namespace Apache.Ignite.Core.Tests.ApiParity
"TimeServerPortBase",
"TimeServerPortRange",
"IncludeProperties",
- "isAutoActivationEnabled", // IGNITE-7301
- "MvccVacuumFrequency", //TODO: IGNITE-9390: Remove when Mvcc support will be added.
- "MvccVacuumThreadCount" //TODO: IGNITE-9390: Remove when Mvcc support will be added.
+ "isAutoActivationEnabled" // IGNITE-7301
};
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
index 68546b9..c9100b2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CachePartitionedTest.cs
@@ -17,6 +17,9 @@
namespace Apache.Ignite.Core.Tests.Cache
{
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Transactions;
using NUnit.Framework;
[Category(TestUtils.CategoryIntensive)]
@@ -41,5 +44,39 @@ namespace Apache.Ignite.Core.Tests.Cache
{
return 1;
}
+
+ /// <summary>
+ /// Test MVCC transaction.
+ /// </summary>
+ [Test]
+ public void TestMvccTransaction()
+ {
+ IIgnite ignite = GetIgnite(0);
+
+ ICache<int, int> cache = ignite.GetOrCreateCache<int, int>(new CacheConfiguration
+ {
+ Name = "mvcc",
+ AtomicityMode = CacheAtomicityMode.TransactionalSnapshot
+ });
+
+ ITransaction tx = ignite.GetTransactions().TxStart();
+
+ cache.Put(1, 1);
+ cache.Put(2, 2);
+
+ tx.Commit();
+
+ Assert.AreEqual(1, cache.Get(1));
+ Assert.AreEqual(2, cache.Get(2));
+
+ tx = ignite.GetTransactions().TxStart();
+
+ Assert.AreEqual(1, cache.Get(1));
+ Assert.AreEqual(2, cache.Get(2));
+
+ tx.Commit();
+
+ ignite.DestroyCache("mvcc");
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
index b091a49..4aa5190 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
@@ -23,7 +23,7 @@
workDirectory='c:' JvmMaxMemoryMb='1024' MetricsLogFrequency='0:0:10' isDaemon='true'
isLateAffinityAssignment='false' springConfigUrl='c:\myconfig.xml' autoGenerateIgniteInstanceName='true'
peerAssemblyLoadingMode='CurrentAppDomain' longQueryWarningTimeout='1:2:3' isActiveOnStart='false'
- consistentId='someId012' redirectJavaConsoleOutput='false' authenticationEnabled='true'>
+ consistentId='someId012' redirectJavaConsoleOutput='false' authenticationEnabled='true' mvccVacuumFrequency='10000' mvccVacuumThreadCount='4'>
<localhost>127.1.1.1</localhost>
<binaryConfiguration compactFooter='false' keepDeserialized='true'>
<nameMapper type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+NameMapper' bar='testBar' />
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index e2ece20..ec9d4fd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -100,6 +100,9 @@ namespace Apache.Ignite.Core.Tests
Assert.IsFalse(cfg.IsActiveOnStart);
Assert.IsTrue(cfg.AuthenticationEnabled);
+ Assert.AreEqual(10000, cfg.MvccVacuumFrequency);
+ Assert.AreEqual(4, cfg.MvccVacuumThreadCount);
+
Assert.IsNotNull(cfg.SqlSchemas);
Assert.AreEqual(2, cfg.SqlSchemas.Count);
Assert.IsTrue(cfg.SqlSchemas.Contains("SCHEMA_1"));
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index a03d09c..2861c30 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -242,6 +242,9 @@ namespace Apache.Ignite.Core.Tests
AssertExtensions.ReflectionEqual(cfg.DataStorageConfiguration, resCfg.DataStorageConfiguration);
+ Assert.AreEqual(cfg.MvccVacuumFrequency, resCfg.MvccVacuumFrequency);
+ Assert.AreEqual(cfg.MvccVacuumThreadCount, resCfg.MvccVacuumThreadCount);
+
Assert.IsNotNull(resCfg.SqlSchemas);
Assert.AreEqual(2, resCfg.SqlSchemas.Count);
Assert.IsTrue(resCfg.SqlSchemas.Contains("SCHEMA_3"));
@@ -498,6 +501,8 @@ namespace Apache.Ignite.Core.Tests
cfg.ClientConnectorConfigurationEnabled);
Assert.AreEqual(IgniteConfiguration.DefaultRedirectJavaConsoleOutput, cfg.RedirectJavaConsoleOutput);
Assert.AreEqual(IgniteConfiguration.DefaultAuthenticationEnabled, cfg.AuthenticationEnabled);
+ Assert.AreEqual(IgniteConfiguration.DefaultMvccVacuumFrequency, cfg.MvccVacuumFrequency);
+ Assert.AreEqual(IgniteConfiguration.DefaultMvccVacuumThreadCount, cfg.MvccVacuumThreadCount);
// Thread pools.
Assert.AreEqual(IgniteConfiguration.DefaultManagementThreadPoolSize, cfg.ManagementThreadPoolSize);
@@ -836,6 +841,8 @@ namespace Apache.Ignite.Core.Tests
}
},
AuthenticationEnabled = false,
+ MvccVacuumFrequency = 20000,
+ MvccVacuumThreadCount = 8,
SqlSchemas = new List<string> { "SCHEMA_3", "schema_4" }
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
index 8c36a77..49e5d12 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
@@ -26,6 +26,13 @@ namespace Apache.Ignite.Core.Cache.Configuration
{
/// <summary>
/// Specifies fully ACID-compliant transactional cache behavior.
+ /// <para />
+ /// <b>Note!</b> In this mode, transactional consistency is guaranteed for key-value API operations only.
+ /// To enable ACID capabilities for SQL transactions, use TRANSACTIONAL_SNAPSHOT mode.
+ /// <para />
+ /// <b>Note!</b> This atomicity mode is not compatible with the other atomicity modes within the same transaction.
+ /// If a transaction is executed over multiple caches, all caches must have the same atomicity mode,
+ /// either TRANSACTIONAL_SNAPSHOT or TRANSACTIONAL.
/// </summary>
Transactional,
@@ -49,6 +56,27 @@ namespace Apache.Ignite.Core.Cache.Configuration
/// Also note that all data modifications in <see cref="Atomic"/> mode are guaranteed to be atomic
/// and consistent with writes to the underlying persistent store, if one is configured.
/// </summary>
- Atomic
+ Atomic,
+
+ /// <summary>
+ /// Specifies fully ACID-compliant transactional cache behavior for both key-value API and SQL transactions.
+ /// <para/>
+ /// This atomicity mode enables multiversion concurrency control (MVCC) for the cache. In MVCC-enabled caches,
+ /// when a transaction updates a row, it creates a new version of that row instead of overwriting it.
+ /// Other users continue to see the old version of the row until the transaction is committed.
+ /// In this way, readers and writers do not conflict with each other and always work with a consistent dataset.
+ /// The old version of data is cleaned up when it's no longer accessed by anyone.
+ /// <para />
+ /// With this mode enabled, one node is elected as an MVCC coordinator. This node tracks all in-flight transactions
+ /// and queries executed in the cluster. Each transaction or query executed over the cache with
+ /// TRANSACTIONAL_SNAPSHOT mode works with a current snapshot of data generated for this transaction or query
+ /// by the coordinator. This snapshot ensures that the transaction works with a consistent database state
+ /// during its execution period.
+ /// <para />
+ /// <b>Note!</b> This atomicity mode is not compatible with the other atomicity modes within the same transaction.
+ /// If a transaction is executed over multiple caches, all caches must have the same atomicity mode,
+ /// either TRANSACTIONAL_SNAPSHOT or TRANSACTIONAL.
+ /// </summary>
+ TransactionalSnapshot,
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index bd53118..315b27d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -205,6 +205,12 @@ namespace Apache.Ignite.Core
/** Map from user-defined listener to it's id. */
private Dictionary<object, int> _localEventListenerIds;
+ /** MVCC vacuum frequency. */
+ private long? _mvccVacuumFreq;
+
+ /** MVCC vacuum thread count. */
+ private int? _mvccVacuumThreadCnt;
+
/// <summary>
/// Default network retry count.
/// </summary>
@@ -231,6 +237,16 @@ namespace Apache.Ignite.Core
public const bool DefaultAuthenticationEnabled = false;
/// <summary>
+ /// Default value for <see cref="MvccVacuumFrequency"/> property.
+ /// </summary>
+ public const long DefaultMvccVacuumFrequency = 5000;
+
+ /// <summary>
+ /// Default value for <see cref="MvccVacuumThreadCount"/> property.
+ /// </summary>
+ public const int DefaultMvccVacuumThreadCount = 2;
+
+ /// <summary>
/// Initializes a new instance of the <see cref="IgniteConfiguration"/> class.
/// </summary>
public IgniteConfiguration()
@@ -309,6 +325,8 @@ namespace Apache.Ignite.Core
writer.WriteTimeSpanAsLongNullable(_longQueryWarningTimeout);
writer.WriteBooleanNullable(_isActiveOnStart);
writer.WriteBooleanNullable(_authenticationEnabled);
+ writer.WriteLongNullable(_mvccVacuumFreq);
+ writer.WriteIntNullable(_mvccVacuumThreadCnt);
if (SqlSchemas == null)
writer.WriteInt(-1);
@@ -675,6 +693,8 @@ namespace Apache.Ignite.Core
_longQueryWarningTimeout = r.ReadTimeSpanNullable();
_isActiveOnStart = r.ReadBooleanNullable();
_authenticationEnabled = r.ReadBooleanNullable();
+ _mvccVacuumFreq = r.ReadLongNullable();
+ _mvccVacuumThreadCnt = r.ReadIntNullable();
int sqlSchemasCnt = r.ReadInt();
@@ -1550,6 +1570,26 @@ namespace Apache.Ignite.Core
}
/// <summary>
+ /// Time interval between MVCC vacuum runs in milliseconds.
+ /// </summary>
+ [DefaultValue(DefaultMvccVacuumFrequency)]
+ public long MvccVacuumFrequency
+ {
+ get { return _mvccVacuumFreq ?? DefaultMvccVacuumFrequency; }
+ set { _mvccVacuumFreq = value; }
+ }
+
+ /// <summary>
+ /// Number of MVCC vacuum threads.
+ /// </summary>
+ [DefaultValue(DefaultMvccVacuumThreadCount)]
+ public int MvccVacuumThreadCount
+ {
+ get { return _mvccVacuumThreadCnt ?? DefaultMvccVacuumThreadCount; }
+ set { _mvccVacuumThreadCnt = value; }
+ }
+
+ /// <summary>
/// Gets or sets predefined failure handlers implementation.
/// A failure handler handles critical failures of Ignite instance accordingly:
/// <para><see cref="NoOpFailureHandler"/> -- do nothing.</para>
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index ebbef67..4040610 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -2265,6 +2265,17 @@
<xs:documentation>Whether user authentication is enabled for the cluster.</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute name="mvccVacuumFrequency" type="xs:long">
+ <xs:annotation>
+ <xs:documentation>Time interval between MVCC vacuum runs in milliseconds.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="mvccVacuumThreadCount" type="xs:int">
+ <xs:annotation>
+ <xs:documentation>Number of MVCC vacuum threads.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="clientConnectorConfigurationEnabled" type="xs:boolean">
<xs:annotation>
<xs:documentation>Whether client connector should be enabled (allow thin clients, ODBC and JDBC drivers to work with Ignite).</xs:documentation>
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
index b13318c..5fca62d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
@@ -79,6 +79,14 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
+ /// Reads the nullable long.
+ /// </summary>
+ public static long? ReadLongNullable(this IBinaryRawReader reader)
+ {
+ return reader.ReadBoolean() ? reader.ReadLong() : (long?) null;
+ }
+
+ /// <summary>
/// Reads the nullable bool.
/// </summary>
public static bool? ReadBooleanNullable(this IBinaryRawReader reader)
http://git-wip-us.apache.org/repos/asf/ignite/blob/45721371/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs
index e504d75..b965bca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs
@@ -44,7 +44,7 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
- /// Writes the nullable boolean.
+ /// Writes the nullable int.
/// </summary>
public static void WriteIntNullable(this IBinaryRawWriter writer, int? value)
{
@@ -58,6 +58,20 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
+ /// Writes the nullable long.
+ /// </summary>
+ public static void WriteLongNullable(this IBinaryRawWriter writer, long? value)
+ {
+ if (value != null)
+ {
+ writer.WriteBoolean(true);
+ writer.WriteLong(value.Value);
+ }
+ else
+ writer.WriteBoolean(false);
+ }
+
+ /// <summary>
/// Writes the timespan.
/// </summary>
public static void WriteTimeSpanAsLong(this IBinaryRawWriter writer, TimeSpan value)
[3/4] ignite git commit: IGNITE-9760 Fixed NPE in WAL manager for
FSYNC mode - Fixes #4888.
Posted by sb...@apache.org.
IGNITE-9760 Fixed NPE in WAL manager for FSYNC mode - Fixes #4888.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a03c6e98
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a03c6e98
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a03c6e98
Branch: refs/heads/ignite-gg-14206
Commit: a03c6e9833e4767025c9aefeedbead07495da4a5
Parents: bd07c83
Author: Anton Kalashnikov <ka...@yandex.ru>
Authored: Tue Oct 2 19:07:36 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Oct 2 19:07:36 2018 +0300
----------------------------------------------------------------------
.../wal/FsyncModeFileWriteAheadLogManager.java | 7 +++--
.../wal/WalRolloverRecordLoggingFsyncTest.java | 32 ++++++++++++++++++++
.../WalRolloverRecordLoggingLogOnlyTest.java | 32 ++++++++++++++++++++
.../db/wal/WalRolloverRecordLoggingTest.java | 16 ++++++----
.../IgnitePdsWithIndexingCoreTestSuite.java | 6 ++--
5 files changed, 83 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a03c6e98/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java
index 1c0325e..3d1b0e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java
@@ -2330,19 +2330,22 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
private abstract static class FileHandle {
/** I/O interface for read/write operations with file */
protected SegmentIO fileIO;
+ /** Segment idx corresponded to fileIo*/
+ final long segmentIdx;
/**
* @param fileIO I/O interface for read/write operations of FileHandle.
*/
- private FileHandle(SegmentIO fileIO) {
+ private FileHandle(@NotNull SegmentIO fileIO) {
this.fileIO = fileIO;
+ this.segmentIdx = fileIO.getSegmentId();
}
/**
* @return Current segment id.
*/
public long getSegmentId(){
- return fileIO.getSegmentId();
+ return segmentIdx;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a03c6e98/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingFsyncTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingFsyncTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingFsyncTest.java
new file mode 100644
index 0000000..7454e5f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingFsyncTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.db.wal;
+
+import org.apache.ignite.configuration.WALMode;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ *
+ */
+public class WalRolloverRecordLoggingFsyncTest extends WalRolloverRecordLoggingTest {
+
+ /** {@inheritDoc} */
+ @NotNull @Override public WALMode walMode() {
+ return WALMode.FSYNC;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a03c6e98/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingLogOnlyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingLogOnlyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingLogOnlyTest.java
new file mode 100644
index 0000000..765fdeb
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingLogOnlyTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.db.wal;
+
+import org.apache.ignite.configuration.WALMode;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ *
+ */
+public class WalRolloverRecordLoggingLogOnlyTest extends WalRolloverRecordLoggingTest {
+
+ /** {@inheritDoc} */
+ @NotNull @Override public WALMode walMode() {
+ return WALMode.LOG_ONLY;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a03c6e98/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java
index 67caf63..395b03a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
import org.apache.ignite.failure.StopNodeOrHaltFailureHandler;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -36,13 +37,11 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH;
-import static org.apache.ignite.configuration.WALMode.LOG_ONLY;
+import org.jetbrains.annotations.NotNull;
/**
*
*/
-public class WalRolloverRecordLoggingTest extends GridCommonAbstractTest {
+public abstract class WalRolloverRecordLoggingTest extends GridCommonAbstractTest {
/** */
private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
@@ -69,15 +68,20 @@ public class WalRolloverRecordLoggingTest extends GridCommonAbstractTest {
.setDefaultDataRegionConfiguration(new DataRegionConfiguration()
.setPersistenceEnabled(true)
.setMaxSize(40 * 1024 * 1024))
- .setWalMode(LOG_ONLY)
+ .setWalMode(walMode())
.setWalSegmentSize(4 * 1024 * 1024)
- .setWalArchivePath(DFLT_WAL_PATH));
+ );
cfg.setFailureHandler(new StopNodeOrHaltFailureHandler(false, 0));
return cfg;
}
+ /**
+ * @return Wal mode.
+ */
+ @NotNull public abstract WALMode walMode();
+
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
stopAllGrids();
http://git-wip-us.apache.org/repos/asf/ignite/blob/a03c6e98/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java
index caea388..e9159bf 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java
@@ -40,7 +40,8 @@ import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalR
import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalRecoveryWithCompactionTest;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalPathsTest;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRecoveryTxLogicalRecordsTest;
-import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRolloverRecordLoggingTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRolloverRecordLoggingFsyncTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRolloverRecordLoggingLogOnlyTest;
/**
* Test suite for tests that cover core PDS features and depend on indexing module.
@@ -60,7 +61,8 @@ public class IgnitePdsWithIndexingCoreTestSuite extends TestSuite {
suite.addTestSuite(PersistenceDirectoryWarningLoggingTest.class);
suite.addTestSuite(WalPathsTest.class);
suite.addTestSuite(WalRecoveryTxLogicalRecordsTest.class);
- suite.addTestSuite(WalRolloverRecordLoggingTest.class);
+ suite.addTestSuite(WalRolloverRecordLoggingFsyncTest.class);
+ suite.addTestSuite(WalRolloverRecordLoggingLogOnlyTest.class);
suite.addTestSuite(IgniteWalRecoveryTest.class);
suite.addTestSuite(IgniteWalRecoveryWithCompactionTest.class);
[2/4] ignite git commit: IGNITE-9761 Fixed deadlock in WAL manager -
Fixes #4890.
Posted by sb...@apache.org.
IGNITE-9761 Fixed deadlock in WAL manager - Fixes #4890.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bd07c835
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bd07c835
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bd07c835
Branch: refs/heads/ignite-gg-14206
Commit: bd07c83583807714757ed033901bf885c9a77b24
Parents: 4572137
Author: Anton Kalashnikov <ka...@yandex.ru>
Authored: Tue Oct 2 18:26:20 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Oct 2 18:26:20 2018 +0300
----------------------------------------------------------------------
.../wal/aware/SegmentArchivedStorage.java | 8 ++--
.../persistence/wal/aware/SegmentAware.java | 9 +++++
.../wal/aware/SegmentLockStorage.java | 27 +++++--------
.../wal/aware/SegmentObservable.java | 10 ++---
.../persistence/wal/aware/SegmentAwareTest.java | 42 +++++++++++++++++++-
5 files changed, 70 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bd07c835/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java
index 1ed607e..c526ae1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java
@@ -63,10 +63,12 @@ class SegmentArchivedStorage extends SegmentObservable {
/**
* @param lastAbsArchivedIdx New value of last archived segment index.
*/
- synchronized void setLastArchivedAbsoluteIndex(long lastAbsArchivedIdx) {
- this.lastAbsArchivedIdx = lastAbsArchivedIdx;
+ void setLastArchivedAbsoluteIndex(long lastAbsArchivedIdx) {
+ synchronized (this) {
+ this.lastAbsArchivedIdx = lastAbsArchivedIdx;
- notifyAll();
+ notifyAll();
+ }
notifyObservers(lastAbsArchivedIdx);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bd07c835/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java
index 6ba0399..e46d93f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java
@@ -220,6 +220,15 @@ public class SegmentAware {
}
/**
+ * Visible for test.
+ *
+ * @param absIdx Segment absolute index. segment later, use {@link #releaseWorkSegment} for unlock</li> </ul>
+ */
+ void lockWorkSegment(long absIdx) {
+ segmentLockStorage.lockWorkSegment(absIdx);
+ }
+
+ /**
* @param absIdx Segment absolute index.
*/
public void releaseWorkSegment(long absIdx) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/bd07c835/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentLockStorage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentLockStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentLockStorage.java
index 2e145e7..f638d4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentLockStorage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentLockStorage.java
@@ -17,8 +17,8 @@
package org.apache.ignite.internal.processors.cache.persistence.wal.aware;
-import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager;
/**
@@ -29,7 +29,7 @@ public class SegmentLockStorage extends SegmentObservable {
* Maps absolute segment index to locks counter. Lock on segment protects from archiving segment and may come from
* {@link FileWriteAheadLogManager.RecordsIterator} during WAL replay. Map itself is guarded by <code>this</code>.
*/
- private Map<Long, Integer> locked = new HashMap<>();
+ private Map<Long, Integer> locked = new ConcurrentHashMap<>();
/**
* Check if WAL segment locked (protected from move to archive)
@@ -37,7 +37,7 @@ public class SegmentLockStorage extends SegmentObservable {
* @param absIdx Index for check reservation.
* @return {@code True} if index is locked.
*/
- public synchronized boolean locked(long absIdx) {
+ public boolean locked(long absIdx) {
return locked.containsKey(absIdx);
}
@@ -47,12 +47,8 @@ public class SegmentLockStorage extends SegmentObservable {
* segment later, use {@link #releaseWorkSegment} for unlock</li> </ul>
*/
@SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext")
- synchronized boolean lockWorkSegment(long absIdx) {
- Integer cur = locked.get(absIdx);
-
- cur = cur == null ? 1 : cur + 1;
-
- locked.put(absIdx, cur);
+ boolean lockWorkSegment(long absIdx) {
+ locked.compute(absIdx, (idx, count) -> count == null ? 1 : count + 1);
return false;
}
@@ -61,15 +57,12 @@ public class SegmentLockStorage extends SegmentObservable {
* @param absIdx Segment absolute index.
*/
@SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext")
- synchronized void releaseWorkSegment(long absIdx) {
- Integer cur = locked.get(absIdx);
-
- assert cur != null && cur >= 1 : "cur=" + cur + ", absIdx=" + absIdx;
+ void releaseWorkSegment(long absIdx) {
+ locked.compute(absIdx, (idx, count) -> {
+ assert count != null && count >= 1 : "cur=" + count + ", absIdx=" + absIdx;
- if (cur == 1)
- locked.remove(absIdx);
- else
- locked.put(absIdx, cur - 1);
+ return count == 1 ? null : count - 1;
+ });
notifyObservers(absIdx);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bd07c835/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentObservable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentObservable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentObservable.java
index ba5ad30..3e91504 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentObservable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentObservable.java
@@ -17,8 +17,8 @@
package org.apache.ignite.internal.processors.cache.persistence.wal.aware;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Consumer;
/**
@@ -26,12 +26,12 @@ import java.util.function.Consumer;
*/
public abstract class SegmentObservable {
/** Observers for handle changes of archived index. */
- private final List<Consumer<Long>> observers = new ArrayList<>();
+ private final Queue<Consumer<Long>> observers = new ConcurrentLinkedQueue<>();
/**
* @param observer Observer for notification about segment's changes.
*/
- synchronized void addObserver(Consumer<Long> observer) {
+ void addObserver(Consumer<Long> observer) {
observers.add(observer);
}
@@ -40,7 +40,7 @@ public abstract class SegmentObservable {
*
* @param segmentId Segment which was been changed.
*/
- synchronized void notifyObservers(long segmentId) {
+ void notifyObservers(long segmentId) {
observers.forEach(observer -> observer.accept(segmentId));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bd07c835/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java
index 7840b09..0869356 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java
@@ -31,6 +31,46 @@ import static org.junit.Assert.assertThat;
* Test for {@link SegmentAware}.
*/
public class SegmentAwareTest extends TestCase {
+
+ /**
+ * Checking to avoid deadlock SegmentArchivedStorage.markAsMovedToArchive -> SegmentLockStorage.locked <->
+ * SegmentLockStorage.releaseWorkSegment -> SegmentArchivedStorage.onSegmentUnlocked
+ *
+ * @throws IgniteCheckedException if failed.
+ */
+ public void testAvoidDeadlockArchiverAndLockStorage() throws IgniteCheckedException {
+ SegmentAware aware = new SegmentAware(10, false);
+
+ int iterationCnt = 100_000;
+ int segmentToHandle = 1;
+
+ IgniteInternalFuture archiverThread = GridTestUtils.runAsync(() -> {
+ int i = iterationCnt;
+
+ while (i-- > 0) {
+ try {
+ aware.markAsMovedToArchive(segmentToHandle);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+
+ IgniteInternalFuture lockerThread = GridTestUtils.runAsync(() -> {
+ int i = iterationCnt;
+
+ while (i-- > 0) {
+ aware.lockWorkSegment(segmentToHandle);
+
+ aware.releaseWorkSegment(segmentToHandle);
+ }
+ });
+
+ archiverThread.get();
+ lockerThread.get();
+ }
+
/**
* Waiting finished when work segment is set.
*/
@@ -435,7 +475,7 @@ public class SegmentAwareTest extends TestCase {
public void testLastCompressedIdxProperOrdering() throws IgniteInterruptedCheckedException {
SegmentAware aware = new SegmentAware(10, true);
- for (int i = 0; i < 5 ; i++) {
+ for (int i = 0; i < 5; i++) {
aware.setLastArchivedAbsoluteIndex(i);
aware.waitNextSegmentToCompress();
}
[4/4] ignite git commit: Merge remote-tracking branch
'remotes/origin/master' into ignite-gg-14206
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-gg-14206
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ba13ed95
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ba13ed95
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ba13ed95
Branch: refs/heads/ignite-gg-14206
Commit: ba13ed9561a07539c6b6a638329d9bb80078fce9
Parents: 17f0178 a03c6e9
Author: sboikov <sb...@apache.org>
Authored: Wed Oct 3 11:11:13 2018 +0300
Committer: sboikov <sb...@apache.org>
Committed: Wed Oct 3 11:11:13 2018 +0300
----------------------------------------------------------------------
.../apache/ignite/cache/CacheAtomicityMode.java | 10 +++--
.../configuration/IgniteConfiguration.java | 30 +++++++-------
.../wal/FsyncModeFileWriteAheadLogManager.java | 7 +++-
.../wal/aware/SegmentArchivedStorage.java | 8 ++--
.../persistence/wal/aware/SegmentAware.java | 9 +++++
.../wal/aware/SegmentLockStorage.java | 27 +++++--------
.../wal/aware/SegmentObservable.java | 10 ++---
.../utils/PlatformConfigurationUtils.java | 8 ++++
.../wal/WalRolloverRecordLoggingFsyncTest.java | 32 +++++++++++++++
.../WalRolloverRecordLoggingLogOnlyTest.java | 32 +++++++++++++++
.../db/wal/WalRolloverRecordLoggingTest.java | 16 +++++---
.../persistence/wal/aware/SegmentAwareTest.java | 42 +++++++++++++++++++-
.../IgnitePdsWithIndexingCoreTestSuite.java | 6 ++-
.../ApiParity/IgniteConfigurationParityTest.cs | 4 +-
.../Cache/CachePartitionedTest.cs | 37 +++++++++++++++++
.../Config/full-config.xml | 2 +-
.../IgniteConfigurationSerializerTest.cs | 3 ++
.../IgniteConfigurationTest.cs | 7 ++++
.../Cache/Configuration/CacheAtomicityMode.cs | 30 +++++++++++++-
.../Apache.Ignite.Core/IgniteConfiguration.cs | 40 +++++++++++++++++++
.../IgniteConfigurationSection.xsd | 11 +++++
.../Impl/Binary/BinaryReaderExtensions.cs | 8 ++++
.../Impl/Binary/BinaryWriterExtensions.cs | 16 +++++++-
23 files changed, 335 insertions(+), 60 deletions(-)
----------------------------------------------------------------------