Issue Details (XML | Word | Printable)

Key: CONF-9434
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Matt Ryall [Atlassian]
Reporter: Gurleen Anand [Atlassian]
Votes: 5
Watchers: 9
Operations

If you were logged in you would be able to see more operations.
Confluence

Enabling Caching for Hibernate Repository causes net.sf.hibernate.LazyInitializationException error

Created: 10/Sep/07 08:41 PM   Updated: 17/Oct/07 09:08 AM
Component/s: Database / Hibernate, External User Management
Affects Version/s: 2.5.6, 2.5.7
Fix Version/s: 2.5.8, 2.6.0, 2.7

Time Tracking:
Not Specified

File Attachments: 1. Java Archive File atlassian-user-confluence-2.5.x-1.9.jar (271 kB)
2. Zip Archive log.zip (10 kB)

Issue Links:
Duplicate
 
Reference
 

Participants: Andrew Miller, Bhavin Turakhia, Charles Hill, Dushyanth Harinath, Gurleen Anand [Atlassian], Ivan Benko [Atlassian], Jonas Sundman, Mark Nye, Matt Ryall [Atlassian] and Stephen Morad
Since last comment: 51 weeks, 5 days ago
Resolution Date: 02/Oct/07 07:21 PM
Labels:


 Description  « Hide
Enabling caching for hibernate repository by adding the cache="true" directive in the atlassian-user.xml file, such as this:
<hibernate name="Hibernate Repository" key="hibernateRepository"  description="Hibernate Repository" cache="true" />

leads to the following exception:

 Cause:
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)

Stack Trace: [hide]

net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
at net.sf.hibernate.collection.Set.contains(Set.java:122)
at com.atlassian.user.impl.hibernate.HibernateGroupManager.hasExternalMembership(HibernateGroupManager.java:461)
at com.atlassian.user.impl.hibernate.HibernateGroupManager.hasMembership(HibernateGroupManager.java:437)
at com.atlassian.user.impl.cache.CachingGroupManager.hasMembership(CachingGroupManager.java:149)
at com.atlassian.user.impl.delegation.DelegatingGroupManagerTemplate.hasMembership(DelegatingGroupManagerTemplate.java:189)


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Matt Ryall [Atlassian] added a comment - 10/Sep/07 08:49 PM
Increasing priority. This seems to be a serious problem.

Andrew Miller added a comment - 10/Sep/07 10:08 PM
If you need any additional logs on this, just let me know.

Bhavin Turakhia added a comment - 15/Sep/07 02:22 AM
is there any ETA on this? this is impacting our live installation

Matt Ryall [Atlassian] added a comment - 16/Sep/07 06:40 PM
We're investigating this issue, and will update as soon as we have more details or an ETA.

Andrew Miller added a comment - 17/Sep/07 03:45 PM
I'm pretty sure that this is the cause of a noticeable slowdown relating to the pagetree and children macros since upgrading from 2.2.10 to 2.5.6 (all users are sourced from LDAP but we have a lot of LDAP and local groups) – it would be wonderful if this could be fixed in the near future!

Mark Nye added a comment - 19/Sep/07 12:31 PM

We're seeing this problem as well. We're running Confluence 2.5.6 with Oracle 10, and doing LDAP authentication from Active Directory. I can consistently reproduce the problem by:

1) Start Confluence.
2) Open two separate browsers, both with no current Confluence sessions
3) browser 1 - log into Confluence as an admin user. Create a new local Confluence user and join the new user to the confluence-administrators group.
4) Log out of Confluence in browser 1
5) In browser 1, log into Confluence as the new user
6) In browser 2, attempt to log in as an LDAP user. The LazyInitializationException error is triggered.
7) Restart Confluence, and the problem goes away.


Dushyanth Harinath added a comment - 20/Sep/07 08:41 AM
  • Iam surprised a critical issue like this is taking so much time to fix.
  • Our enterprise confluence instance needs to be restarted every 2 hrs.
  • Please update on the status

Charles Hill added a comment - 20/Sep/07 08:46 AM
Dushyanth,

Remove the cache="true" from the <hibernate line of your Atlassian-users.xml to "work around" this bug.

Thanks,

Charles Kevin Hill


Dushyanth Harinath added a comment - 20/Sep/07 08:55 AM
Hi Charles,

Thanks,
Dushyanth


Mark Nye added a comment - 20/Sep/07 09:09 AM
That's right, Dushyanth. We're stuck between the same rock and hard place.

Stephen Morad added a comment - 21/Sep/07 07:53 AM
Here's an easier way to replicate the problem:
  1. Start Confluence
  2. Login as a DB administrator
  3. Logout
  4. Login as an LDAP administrator
  5. Boom!

I'm not sure if the user must be an admin in either or both cases, but in my test (3 times in a row) they were. In another test, logging in as an LDAP user first allowed the instance to run for 30 minutes before crashing.


Jonas Sundman added a comment - 21/Sep/07 09:45 AM
We are experiencing this problem, too. Apparently the cache functionality changed when going to 2.5.6 (CONF-9303).

Without caching every operation that involves multiple pages (e.g. pagetree, contentbylabel) takes at worst tens of times longer to process in authenticated sessions. For more details refer to https://support.atlassian.com/browse/CSP-11453.


Jonas Sundman added a comment - 24/Sep/07 02:22 AM
When examinating our log files, I noticed the same error messages as in the description, even though caching is not enabled for hibernate. They occur together with a getUserFromCookie failure tens of times a day and are not visible to the users, as far as I know.
2007-09-19 14:24:02,758 ERROR [http-8080-Processor16] [net.sf.hibernate.LazyInitializationException] <init> Failed to lazily initialize a collection
- no session or session was closed
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
        at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)
--
2007-09-19 14:24:02,762 WARN [http-8080-Processor16] [atlassian.seraph.auth.DefaultAuthenticator] getUserFromCookie Cookie login failed with exception: net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
        at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)

Matt Ryall [Atlassian] added a comment - 24/Sep/07 08:32 PM
The attached atlassian-user JAR includes a fix for this issue in Confluence 2.5.6 and 2.5.7. To install it, please do the following:
  • shut down Confluence
  • put the attached JAR, 'atlassian-user-confluence-2.5.x-1.9.jar', into confluence/WEB-INF/lib/
  • remove the old atlassian-user JAR from confluence/WEB-INF/lib/ (it should be called 'atlassian-user-1.5-stable-compatible-1.jar')
  • start up Confluence again.

If you still experience the problem after restarting Confluence with this new JAR, please attach a copy of the complete stack trace to this issue.


Jonas Sundman added a comment - 25/Sep/07 03:30 AM
After an hour in our QA environment the perfomace after applying the fix is very promising!

How mature for production should this fix be seen as?


Andrew Miller added a comment - 25/Sep/07 05:02 PM
Major speed improvement here – previously using children=2 in menus for a space using Builder was unusable (30-40 seconds per page load) – it's now quite snappy.

Matt Ryall [Atlassian] added a comment - 25/Sep/07 06:14 PM
The fix has been tested thoroughly here, and will be shipped in the next version of Confluence. The updated JAR actually includes two fixes:
  • a very small code change to the core HibernateGroupManager to fix this issue
  • a more significant change to the OSUser->Hibernate migrator for CONF-9117 and CONF-9195. (The migrator is not used during normal operations, only for the initial LDAP configuration.)

However, I'd still recommend evaluating this in your test environment for any situation we may have missed. Particularly with LDAP user management, every configuration is different, and you should perform testing before putting any patch into production.


Ivan Benko [Atlassian] added a comment - 26/Sep/07 11:17 PM - edited
Note: caching is enabled by default in Confluence 2.5.7, if you used a copy of the shipped atlassian-user.xml.

For the previous versions, or if you have customised atlassian-user.xml, please do the following:

  • Download the patch and install into the specified location
  • Ensure the Hibernate tag in confluence/WEB-INF/classes/atlassian-user.xml has caching enabled, with cache="true":
<hibernate name="Hibernate Repository" key="hibernateRepository"  description="Hibernate Repository" cache="true"/>

Stephen Morad added a comment - 27/Sep/07 10:36 AM
Is this issue isolated to 2.5.6 & 2.5.7? Namely, is it something that could effect 2.6.0 released today?

Matt Ryall [Atlassian] added a comment - 27/Sep/07 07:01 PM
This is fixed in 2.6.0. We're considering a 2.5.8 release so people can get a "stable" release with this fix. I will update the fix versions on this issue as appropriate.

Stephen Morad added a comment - 16/Oct/07 06:02 AM
Has any of the customers on this list tried 2.5.8 yet? If so, what is your experience? I'm a little gun shy of upgrading since this bug bit our production deployment really baddly. Any input from customers out there?

Andrew Miller added a comment - 16/Oct/07 07:39 AM
Running 2.5.6 here with the jar posted above with zero problems for 3 weeks now.

2.5.7 and 2.5.8 were pretty minor updates (other than this fix) so just didn't have much incentive to upgrade (waiting on a later 2.6 or 2.7 release).


Jonas Sundman added a comment - 17/Oct/07 09:08 AM
No problems here either, running 2.5.7 with the patch.