Re: [ZODB-Dev] RelStorage breaks history tab - solution?

2012-05-23 Thread Chris Withers

Hi Shane,

On 23/05/2012 16:27, Chris Withers wrote:

Okay, the issue appears to be that, in some circumstances, RelStorage is
leaving the read connection with an open transaction that isn't rolled
back.


Upon investigation, this turns out to be the history method itself! :-)

Switching to the following patch also solves the problem:

diff --git a/relstorage/storage.py b/relstorage/storage.py
index 2d592d3..3fa792b 100644
--- a/relstorage/storage.py
+++ b/relstorage/storage.py
@@ -1053,6 +1053,7 @@ class RelStorage(
 break
 return res
 finally:
+self._load_conn.rollback()
 self._lock_release()

 def undo(self, transaction_id, transaction):

However, that raised more questions for me:

- How does RelStorage usually rollback the _load_conn in a non-write 
transaction?


- Why doesn't this kick in when viewing the history method?

My guess as to why 
ZODB.tests.HistoryStorage:HistoryStorage.checkSimpleHistory passes is 
that everything is done with the same thread/connection, and so a 
consistent view of the data is seen.


More confusing: having dropped the zserver-threads down to one and from 
looking at the results of:


select * from pg_catalog.pg_stat_activity where datname='myrelstorage';

...it appears that there's:

- one connection for reads

- one connection for writes, which is opened when first used.

Okay, as expected.

- one connection for viewing history.

I can't see where/why this final connection is opened...

Shane, little help?

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
___
For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] RelStorage breaks history tab

2012-05-23 Thread Shane Hathaway

On 05/23/2012 09:27 AM, Chris Withers wrote:

Okay, the issue appears to be that, in some circumstances, RelStorage is
leaving the read connection with an open transaction that isn't rolled
back.


That is what RelStorage is designed to do when you set poll-interval. 
Does the bug go away when you set poll-interval to 0?


Shane
___
For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] RelStorage breaks history tab

2012-05-23 Thread Chris Withers

Hi Shane,

On 22/05/2012 06:37, Chris Withers wrote:

So, the problem is that, with a Zope 2 app server, any revisions made to
an object (say, a Page Template) don't show in the history tab of that
object *until* the app server is restarted.


Okay, the issue appears to be that, in some circumstances, RelStorage is 
leaving the read connection with an open transaction that isn't rolled back.


I couldn't find the source of this, but in the meantime, I less 
heavyweight hack is:


diff --git a/relstorage/storage.py b/relstorage/storage.py
index 2d592d3..459469b 100644
--- a/relstorage/storage.py
+++ b/relstorage/storage.py
@@ -1025,6 +1025,7 @@ class RelStorage(
 self._lock_acquire()
 try:
 self._before_load()
+self._load_conn.rollback()
 cursor = self._load_cursor
 oid_int = u64(oid)
 try:

However, that open transaction is likely to cause other problems (I'm 
fairly certain I've seen other effects of this) so do you have any idea 
where to look for it?


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
___
For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zodb-dev