Skip to content

Commit fa7265f

Browse files
rvansagalderz
authored andcommitted
HHH-9881 Pending put needs to be invalidated on update on remote node
* This could lead to performance degradation since new EndInvalidatingCommand needs to be send after transaction is committed
1 parent 4b2a787 commit fa7265f

16 files changed

+1053
-368
lines changed

hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ public class InfinispanRegionFactory implements RegionFactory {
214214
*/
215215
public static final String PENDING_PUTS_CACHE_NAME = "pending-puts";
216216

217+
/**
218+
* A local, lightweight cache for pending puts, which is
219+
* non-transactional and has aggressive expiration settings.
220+
* Locking is still required since the putFromLoad validator
221+
* code uses conditional operations (i.e. putIfAbsent)
222+
*/
223+
public static final Configuration PENDING_PUTS_CACHE_CONFIGURATION = new ConfigurationBuilder()
224+
.clustering().cacheMode(CacheMode.LOCAL)
225+
.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL)
226+
.expiration().maxIdle(TimeUnit.SECONDS.toMillis(60))
227+
.storeAsBinary().enabled(false)
228+
.locking().isolationLevel(IsolationLevel.READ_COMMITTED)
229+
.jmxStatistics().disable().build();
230+
217231
private EmbeddedCacheManager manager;
218232

219233
private final Map<String, TypeOverrides> typeOverrides = new HashMap<String, TypeOverrides>();
@@ -345,7 +359,7 @@ public AccessType getDefaultAccessType() {
345359

346360
@Override
347361
public long nextTimestamp() {
348-
return System.currentTimeMillis() / 100;
362+
return System.currentTimeMillis();
349363
}
350364

351365
public void setCacheManager(EmbeddedCacheManager manager) {
@@ -374,7 +388,7 @@ public void start(SessionFactoryOptions settings, Properties properties) throws
374388
}
375389
}
376390
defineGenericDataTypeCacheConfigurations( properties );
377-
definePendingPutsCache();
391+
manager.defineConfiguration( PENDING_PUTS_CACHE_NAME, PENDING_PUTS_CACHE_CONFIGURATION );
378392
}
379393
catch (CacheException ce) {
380394
throw ce;
@@ -384,22 +398,6 @@ public void start(SessionFactoryOptions settings, Properties properties) throws
384398
}
385399
}
386400

387-
private void definePendingPutsCache() {
388-
final ConfigurationBuilder builder = new ConfigurationBuilder();
389-
// A local, lightweight cache for pending puts, which is
390-
// non-transactional and has aggressive expiration settings.
391-
// Locking is still required since the putFromLoad validator
392-
// code uses conditional operations (i.e. putIfAbsent).
393-
builder.clustering().cacheMode( CacheMode.LOCAL )
394-
.transaction().transactionMode( TransactionMode.NON_TRANSACTIONAL )
395-
.expiration().maxIdle( TimeUnit.SECONDS.toMillis( 60 ) )
396-
.storeAsBinary().enabled( false )
397-
.locking().isolationLevel( IsolationLevel.READ_COMMITTED )
398-
.jmxStatistics().disable();
399-
400-
manager.defineConfiguration( PENDING_PUTS_CACHE_NAME, builder.build() );
401-
}
402-
403401
protected org.infinispan.transaction.lookup.TransactionManagerLookup createTransactionManagerLookup(
404402
SessionFactoryOptions settings, Properties properties) {
405403
return new HibernateTransactionManagerLookup( settings, properties );

0 commit comments

Comments
 (0)