[infinispan-issues] [JBoss JIRA] (ISPN-1609) A put with FAIL_SILENT which fails should not be allowed to retain the value in the transaction ctx
Galder Zamarreño (Updated) (JIRA)
jira-events at lists.jboss.org
Thu Dec 15 11:49:09 EST 2011
[ https://issues.jboss.org/browse/ISPN-1609?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Galder Zamarreño updated ISPN-1609:
-----------------------------------
Priority: Blocker (was: Major)
@Mircea, is the order in PessimisticLockingInterceptor.visitPutKeyValueCommand() right? Basically, you're invoking first:
{code}Object result = invokeNextInterceptor(ctx, command);{code}
which, amongst other things, changes the value of the CacheEntry to be v3
And then you acquired the lock in:
{code}lockKeyAndCheckOwnership(ctx, command.getKey());{code}
Shouldn't you acquire the lock and then move on in the interceptor stack? This would avoid this issue.
@Mircea, I'm assigning this to you, is that Ok?
> A put with FAIL_SILENT which fails should not be allowed to retain the value in the transaction ctx
> ---------------------------------------------------------------------------------------------------
>
> Key: ISPN-1609
> URL: https://issues.jboss.org/browse/ISPN-1609
> Project: Infinispan
> Issue Type: Bug
> Affects Versions: 5.1.0.CR1
> Reporter: Galder Zamarreño
> Assignee: Galder Zamarreño
> Priority: Blocker
> Fix For: 5.1.0.CR2
>
>
> Imagine this scenario:
> # Call put key=k and value="v1"
> # Within transaction tx1, call put for key=k, value="v2" and stop the tx.
> # Within a separate transaction tx2, call put with FAIL_SILENT for key=x and value="v3"
> # put call in tx2 should fail
> # within tx2 call get(k), this should return "v1" since that's the last valid committed value -> currently it returns "v3" which is wrong
> Code:
> {code} public void testSilentLockFailureAffectsPostOperations() throws Exception {
> final Cache<Integer, String> cache = cache(0);
> final TransactionManager tm = cache.getAdvancedCache().getTransactionManager();
> final ExecutorService e = Executors.newCachedThreadPool();
> final CountDownLatch waitLatch = new CountDownLatch(1);
> final CountDownLatch continueLatch = new CountDownLatch(1);
> cache.put(1, "v1");
> Future<Void> f1 = e.submit(new Callable<Void>() {
> @Override
> public Void call() throws Exception {
> tm.begin();
> try {
> cache.put(1, "v2");
> waitLatch.countDown();
> continueLatch.await();
> } catch (Exception e) {
> tm.setRollbackOnly();
> throw e;
> } finally {
> if (tm.getStatus() == Status.STATUS_ACTIVE) tm.commit();
> else tm.rollback();
> }
> return null;
> }
> });
> Future<Void> f2 = e.submit(new Callable<Void>() {
> @Override
> public Void call() throws Exception {
> waitLatch.await();
> tm.begin();
> try {
> AdvancedCache<Integer, String> silentCache = cache.getAdvancedCache().withFlags(
> Flag.FAIL_SILENTLY, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT);
> silentCache.put(1, "v3");
> assert !silentCache.lock(1);
> assert "v1".equals(cache.get(1));
> } catch (Exception e) {
> tm.setRollbackOnly();
> throw e;
> } finally {
> if (tm.getStatus() == Status.STATUS_ACTIVE) tm.commit();
> else tm.rollback();
> continueLatch.countDown();
> }
> return null;
> }
> });
> f1.get();
> f2.get();
> }{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the infinispan-issues
mailing list