Details
-
Bug
-
Resolution: Fixed
-
Medium
-
2.8
Description
There is a repeated pattern in upgrade tasks to get a Datasource like this -
private DataSource getDataSource() { Session hibernateSession = SessionFactoryUtils.getSession(sessionFactory, true); Connection conn; try { conn = hibernateSession.connection(); } catch (HibernateException e) { throw new RuntimeException(e); } return new SingleConnectionDataSource(conn, true); }
However this has a bug that could cause database connectivity to be lost during the upgrade.
You return from the method a datasource containing a connection returned from a Hibernate session and then continue to use this datasource during the upgrade operations. However, the Hibernate session has since gone out of scope and at some point soon as the SessionImpl is garbage collected and finalized the connection within your datasource is going to be closed.
This affects the following in Confluence -
ConvertAdministerConfluenceToSystemAdministratorUpgradeTask
CorrectAttachmentCreatorUpgradeTask
PersonalInformationRepairTask
OSUEntityMigrator
It's just a matter of timing that determines whether these upgrade tasks will be successful or not