[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-10-21 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14966685#comment-14966685
 ] 

Jacques Le Roux commented on OFBIZ-5534:


Lack of communication does not help :(

> Dirty reads from entity cache
> -
>
> Key: OFBIZ-5534
> URL: https://issues.apache.org/jira/browse/OFBIZ-5534
> Project: OFBiz
>  Issue Type: Bug
>  Components: framework
>Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
> Branch 13.07, Trunk
>Reporter: Jacopo Cappellato
>Assignee: Adam Heath
> Attachments: unittest-dirtyreadsfromcache.patch
>
>
> Even if database transaction isolation level is set to "ReadCommitted", a 
> transaction can get uncommitted records from the entity cache, under certain 
> circumstances.
> Here is a test case:
> 1) transaction T1 creates a record
> 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
> can read data generated in T1 even if not committed) and the record will be 
> added to the cache
> 3) T1 calls another service with requireNewTransaction set to true: this will 
> run the second service in a new transaction T2
> 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
> to false it should fail; if useCache is set to true it will succeed (getting 
> the record from cache, even if the data is not committed to the db)
> The result in #4 is wrong because T2 should not see the uncommitted record
> We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-10-17 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14961869#comment-14961869
 ] 

Jacques Le Roux commented on OFBIZ-5534:


What is the status is? Will you replace Adrian's solution Adam?

> Dirty reads from entity cache
> -
>
> Key: OFBIZ-5534
> URL: https://issues.apache.org/jira/browse/OFBIZ-5534
> Project: OFBiz
>  Issue Type: Bug
>  Components: framework
>Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
> Branch 13.07, Trunk
>Reporter: Jacopo Cappellato
>Assignee: Adam Heath
> Attachments: unittest-dirtyreadsfromcache.patch
>
>
> Even if database transaction isolation level is set to "ReadCommitted", a 
> transaction can get uncommitted records from the entity cache, under certain 
> circumstances.
> Here is a test case:
> 1) transaction T1 creates a record
> 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
> can read data generated in T1 even if not committed) and the record will be 
> added to the cache
> 3) T1 calls another service with requireNewTransaction set to true: this will 
> run the second service in a new transaction T2
> 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
> to false it should fail; if useCache is set to true it will succeed (getting 
> the record from cache, even if the data is not committed to the db)
> The result in #4 is wrong because T2 should not see the uncommitted record
> We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-10-17 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14961924#comment-14961924
 ] 

Adrian Crum commented on OFBIZ-5534:


FYI - my pk cache fix worked, but there were a number of bug reports afterward. 
The fix design depended on the wrapping transaction, but there are places in 
OFBiz where a transaction isn't used - so those places are where the bugs 
appeared.

> Dirty reads from entity cache
> -
>
> Key: OFBIZ-5534
> URL: https://issues.apache.org/jira/browse/OFBIZ-5534
> Project: OFBiz
>  Issue Type: Bug
>  Components: framework
>Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
> Branch 13.07, Trunk
>Reporter: Jacopo Cappellato
>Assignee: Adam Heath
> Attachments: unittest-dirtyreadsfromcache.patch
>
>
> Even if database transaction isolation level is set to "ReadCommitted", a 
> transaction can get uncommitted records from the entity cache, under certain 
> circumstances.
> Here is a test case:
> 1) transaction T1 creates a record
> 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
> can read data generated in T1 even if not committed) and the record will be 
> added to the cache
> 3) T1 calls another service with requireNewTransaction set to true: this will 
> run the second service in a new transaction T2
> 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
> to false it should fail; if useCache is set to true it will succeed (getting 
> the record from cache, even if the data is not committed to the db)
> The result in #4 is wrong because T2 should not see the uncommitted record
> We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-03-21 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14372752#comment-14372752
 ] 

Adrian Crum commented on OFBIZ-5534:


I committed a fix for the PK cache in rev 1668267. Comments are welcome.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
 Branch 13.07, Trunk
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-03-20 Thread Jacopo Cappellato (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14371089#comment-14371089
 ] 

Jacopo Cappellato commented on OFBIZ-5534:
--

I didn't have time to review the proposed solutions in detail but, rather than 
continuing to invest our time in the enhancements of our home grown cache 
system, I would be more inclined to consider the adoption of an external system.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
 Branch 13.07, Trunk
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-03-20 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14371095#comment-14371095
 ] 

Adrian Crum commented on OFBIZ-5534:


Switching to another system is fine, but in the meantime we have a serious flaw 
that needs to be fixed, and it appears I am the only person willing to fix it.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
 Branch 13.07, Trunk
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-03-20 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14371025#comment-14371025
 ] 

Adrian Crum commented on OFBIZ-5534:


Currently, my implementation has issues if transactions are suspended and 
resumed.

You can associate a temporary/local cache to each transaction (like I mentioned 
earlier). Transactions will need to support listeners. On post-commit 
notification: temporary/local cache is copied to global cache. On rollback 
notification: temporary/local cache is emptied.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
 Branch 13.07, Trunk
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-03-20 Thread Ron Wheeler (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14371416#comment-14371416
 ] 

Ron Wheeler commented on OFBIZ-5534:


If you are going to fix the current system, at step 2b) you might consider just 
clearing the transaction cache and internal cache and let the next request 
reload the cache from the database.
This might be simpler and might avoid possible race conditions between 
transactions - or at least let the database sort out who won.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
 Branch 13.07, Trunk
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-03-20 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14371592#comment-14371592
 ] 

Adrian Crum commented on OFBIZ-5534:


Interesting... I changed the transaction timeout value to 1 second for the 
testServiceForDirtyReadsFromCacheT2 service, but it still takes a very long 
time before the transaction times out.

Also, we can't use services for testing this, because even though I catch the 
exception thrown by the timeout, the entity engine has rolled back the 
transaction - which causes the service engine to throw an exception on return. 
So, even though the test passes functionally, it fails because of the 
transaction rollback.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
 Branch 13.07, Trunk
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-03-20 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14371528#comment-14371528
 ] 

Adrian Crum commented on OFBIZ-5534:


I have this fixed on my local copy, but the unit test fails due to the Derby 
deadlock problem that Jacopo discovered.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
 Branch 13.07, Trunk
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2015-03-20 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14371066#comment-14371066
 ] 

Adrian Crum commented on OFBIZ-5534:


This issue is now a year old, and I would like to help get it resolved. Until 
Adam can produce his solution, I have my own that we can consider.

I don't think we need to use XAResource. The problem is fairly easy to solve, 
so using XAResource will complicate things unnecessarily.

1. We need to add a bit of functionality to the existing transaction code:
  a. Associate org.ofbiz.entity.cache.Cache instances (one for each Delegator 
instance) to each UserTransaction instance.
  b. Add Publish/Subscribe (listener) functionality to TransactionUtil. 
Listeners are notified post-commit and post-rollback.

2. Add functionality to the Delegator:
  a. Make each instance a transaction listener.
  b. On post-commit notification, copy transaction cache to internal cache.
  c. On post-rollback notification, clear transaction cache.

3. Modify Delegator cache behavior:
  a. On find methods, check its internal cache first.
  b. If a miss and transaction is in place, check transaction cache.
  c. If a miss, execute SQL SELECT.
  d. If a transaction is in place, put results in transaction cache, else put 
results in internal cache.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, Release Branch 12.04, Release 
 Branch 13.07, Trunk
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adam Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044784#comment-14044784
 ] 

Adam Heath commented on OFBIZ-5534:
---

Well, to do what you would need, would be rather difficult(I think).  Here's 
what would have to happen.

* Allow any pre-existing cached results to be returned.
* Allow new values to be stored into the cache.
* Any values modified during a transaction place a 'whiteout' entry
* Whiteout entries will prevent reading of cached items that match.
* Whiteout entries will prevent storing of items that match into the cache.
* Whiteout entries will clear the cache at the end of the transaction.

Altho, maybe not so difficult.  The changes I have I did entirely last night.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044825#comment-14044825
 ] 

Adrian Crum commented on OFBIZ-5534:


I think it would be fairly straightforward:

1. Remove all code from the delegator that updates the cache. Replace it with a 
call to the transaction manager - passing the entity value as an argument.
2. The transaction manager stores the entity value in a list.
3. When the transaction manager has a successful commit, the entity values in 
the list are placed in the cache.

The result: Updated entity values do not appear in the cache until the 
transaction has been committed successfully.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adam Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044834#comment-14044834
 ] 

Adam Heath commented on OFBIZ-5534:
---

Not just entities.  Lists of entities.  With different orderings.  And objects 
stored into the condition cache.  And removals of other items from the cache.

The best place to do this change is in the actual Cache class.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044840#comment-14044840
 ] 

Adrian Crum commented on OFBIZ-5534:


There is a flaw in my plan: Code might try to read/find an updated value, and 
it will get the original/unmodified value from the cache instead of the updated 
value. Maybe cache reads should go to the transaction manager as well. The tx 
mgr looks in its list of pending changes, and if the entity value isn't in the 
list, it delegates to the delegator.

It is an interesting problem to solve. I think it will require changing how 
transactions are handled, instead of re-engineering the cache.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044845#comment-14044845
 ] 

Adrian Crum commented on OFBIZ-5534:


I don't think the various internal cache lists are a concern. Keep in mind the 
essence of fixing the issue is to prevent an entity value from being stored in 
the cache before it is committed.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044855#comment-14044855
 ] 

Adrian Crum commented on OFBIZ-5534:


Btw, I'm not arguing with you, I'm just trying to whiteboard some ideas.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adam Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044864#comment-14044864
 ] 

Adam Heath commented on OFBIZ-5534:
---

Keeping the list of entities from being polluted is the same as keeping the 
findOne cache clean as well.  The code inside the first transaction may update 
a value, then call findList(), and the results get cached, and now another 
thread will see it.

Trust me, the place for these changes is in the Cache object.  I've already 
been playing around with XAResource and Synchronization.  And I already have 
the cache mutations being delayed and replayed at the end of the transaction.  
I just don't allow for any cache reads while inside the transaction, which does 
cause a slowdown.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044887#comment-14044887
 ] 

Adrian Crum commented on OFBIZ-5534:


I understand your approach, but I don't like it.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adam Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044913#comment-14044913
 ] 

Adam Heath commented on OFBIZ-5534:
---

What don't you like about it?  We can't modify the delegator; external code 
uses the Cache class directly.  This is the only way to store built-up objects 
into the entity condition list classes.

I don't think you are understanding my approach, because what you outlined as 
the way to do things, is how it is being done.  I'm just doing it in Cache, not 
GenericDelegator.

ps: Currently, my implementation has issues if transactions are suspended and 
resumed.  The only way to fix that would be to use XAResource, but there is no 
way to prevent duplication enlistResource calls that is not hackish.

pps: I know that my impl isn't visible yet anywhere.  I don't have time to 
place it someplace that is easy to look at right now.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044923#comment-14044923
 ] 

Adrian Crum commented on OFBIZ-5534:


I don't like the blocking aspect of it. Plus, it sounds overly complicated, but 
that might be due to the fact that I can't see the actual changes.

I was hoping we could work together to design a non-blocking solution. Perhaps 
we need to create a branch to try out ideas.



 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adam Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044958#comment-14044958
 ] 

Adam Heath commented on OFBIZ-5534:
---

Blocking aspect?

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044982#comment-14044982
 ] 

Jacques Le Roux commented on OFBIZ-5534:


A branch seems the best way to me

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Adam Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044989#comment-14044989
 ] 

Adam Heath commented on OFBIZ-5534:
---

Except I really really really don't want to use svn branches.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-26 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14045012#comment-14045012
 ] 

Jacques Le Roux commented on OFBIZ-5534:


I never tried, but then maybe there https://github.com/apache/ofbiz ?

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-25 Thread Adam Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14043977#comment-14043977
 ] 

Adam Heath commented on OFBIZ-5534:
---

The way I fix this issue, is to have the delegator detect that a transaction is 
active, and skip reading from the cache, then register a completion handler in 
on the transaction, and during commit, clear out the cached entries.

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-25 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044047#comment-14044047
 ] 

Adrian Crum commented on OFBIZ-5534:


The way I would fix it would be to have the delegator notify the transaction 
handler about a create/update but not put the entity value in the cache. The 
transaction handler keeps a list of created/updated entity values, and when the 
commit is successful, the transaction manager puts the values in the cache.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-25 Thread Adam Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044331#comment-14044331
 ] 

Adam Heath commented on OFBIZ-5534:
---

Ok.  I've got an implementation that works, sorta, locally.  All existing test 
cases pass.  I then applied the patch(which still had no offsets/conflicts with 
trunk).  And got an error.

In the comments for service T2, there is a commented out block, that mentions a 
dead-lock occurring on derby.  This is because thread T1 has created a new 
value(12345) inside a transaction, which hasn't yet been commited to the 
database.  Then, in thread T2, an attempt to read that value occurs.  But since 
it hasn't yet been committed, you would think that derby would return no 
result.   I haven no idea why it blocks, waiting on the other transaction.  I 
might consider this a bug in derby.

Basically, my change, is to detect that a transaction is active, and disable 
all cache reads; basically, all the read methods org.ofbiz.entity.cache.Cache 
return null.  Then, all put/remove methods in that same class are delayed, and 
are run at the end of the transaction(by making use of a Synchronization).

 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-06-25 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14044351#comment-14044351
 ] 

Adrian Crum commented on OFBIZ-5534:


...is to detect that a transaction is active, and disable all cache reads...

I might be missing something, but it seems to me this effectively disables the 
cache. Nearly every service call is wrapped in a transaction, and screen 
widgets wrap screen rendering in a transaction - so pretty much everything 
OFBiz does is in a transaction.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
Assignee: Adam Heath
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-02-07 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13894857#comment-13894857
 ] 

Adrian Crum commented on OFBIZ-5534:


In addition to the problem you describe, we also have a potential problem with 
rollbacks. Consider a transaction with multiple updates - let's say we issue a 
commit after each update, then put the updated value in the cache. Then later 
in the same transaction, an update attempt triggers a rollback. The previously 
updated values are left in the cache - they are not removed.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)


[jira] [Commented] (OFBIZ-5534) Dirty reads from entity cache

2014-02-07 Thread Adrian Crum (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-5534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13894873#comment-13894873
 ] 

Adrian Crum commented on OFBIZ-5534:


My description might not be clear to those who aren't familiar with the 
framework transaction-handling code. With the current design, the first bit of 
code to update the datasource holds a boolean value indicating it started the 
transaction. Other bits of code that update the datasource will invoke a commit 
method, but it does nothing because those bits of code did not start the 
transaction. When program execution returns to the first bit of code and it 
invokes the commit method, the commit is actually performed on the datasource - 
because that bit of code started the transaction.

So, even when you see code that calls a commit method, the transaction might 
not be actually committed, but instead the update is logged and deferred until 
the real commit is performed.


 Dirty reads from entity cache
 -

 Key: OFBIZ-5534
 URL: https://issues.apache.org/jira/browse/OFBIZ-5534
 Project: OFBiz
  Issue Type: Bug
  Components: framework
Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, 
 Release Branch 13.07
Reporter: Jacopo Cappellato
 Attachments: unittest-dirtyreadsfromcache.patch


 Even if database transaction isolation level is set to ReadCommitted, a 
 transaction can get uncommitted records from the entity cache, under certain 
 circumstances.
 Here is a test case:
 1) transaction T1 creates a record
 2) T1 calls findOne to retrieve it: the read will be successful (because T1 
 can read data generated in T1 even if not committed) and the record will be 
 added to the cache
 3) T1 calls another service with requireNewTransaction set to true: this will 
 run the second service in a new transaction T2
 4) T2 calls findOne to retrieve the record created by T1: if useCache is set 
 to false it should fail; if useCache is set to true it will succeed (getting 
 the record from cache, even if the data is not committed to the db)
 The result in #4 is wrong because T2 should not see the uncommitted record
 We should never add uncommitted records to the entity cache.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)