Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365602 - [DB] Crash restore exception in DBStore for Postgres SQL
Summary: [DB] Crash restore exception in DBStore for Postgres SQL
Status: CLOSED DUPLICATE of bug 364809
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.db (show other bugs)
Version: 4.2   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Stefan Winkler CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-05 09:43 EST by Christophe Bouhier CLA
Modified: 2013-06-27 04:00 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe Bouhier CLA 2011-12-05 09:43:03 EST
If some how the CDO server crashes or is killed, it's not possible to re-connect to the Postgres DB, 
the exception below will occur. Postgres is expecting a rollback.

Postgres 8.3 and 8.4 


!ENTRY org.eclipse.equinox.app 4 0 2011-12-05 13:46:45.523
!MESSAGE org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
!STACK 0
org.eclipse.net4j.db.DBException: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.ObjectTypeTable.getMaxID(ObjectTypeTable.java:185)
at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.DelegatingObjectTypeMapper.getMaxID(DelegatingObjectTypeMapper.java:85)
at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.AbstractHorizontalMappingStrategy.repairAfterCrash(AbstractHorizontalMappingStrategy.java:88)
at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalMappingStrategy.repairAfterCrash(HorizontalMappingStrategy.java:204)
at org.eclipse.emf.cdo.server.internal.db.DBStore.repairAfterCrash(DBStore.java:652)
at org.eclipse.emf.cdo.server.internal.db.DBStore.reStart(DBStore.java:636)
at org.eclipse.emf.cdo.server.internal.db.DBStore.doActivate(DBStore.java:546)
at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:72)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:99)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:89)
at org.eclipse.emf.cdo.internal.server.Repository.doActivate(Repository.java:1543)
at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:72)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:99)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:89)
at org.eclipse.emf.cdo.server.CDOServerUtil.addRepository(CDOServerUtil.java:201)
at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.configure(RepositoryConfigurator.java:110)
at org.eclipse.emf.cdo.internal.server.bundle.CDOServerApplication.doStart(CDOServerApplication.java:61)
at org.eclipse.net4j.util.om.OSGiApplication.start(OSGiApplication.java:61)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.equinox.internal.app.AnyThreadAppLauncher.run(AnyThreadAppLauncher.java:26)
Comment 1 Eike Stepper CLA 2011-12-05 11:44:14 EST
Stefan, can you have a look what Postgres is messing up here? It seems to be a PITA ;-(
Comment 2 Christophe Bouhier CLA 2011-12-13 03:42:19 EST
This change to ObjectTypeTable in the method below solved the problem.  (Adding autocommit to the connection). 
I found later versions of Postgres, would handle this error with autocommit. It's propably not 
the best solution, but at least for me it solved the issue. 


  public CDOID getMaxID(Connection connection, IIDHandler idHandler)
  {
    Statement stmt = null;
    ResultSet resultSet = null;

    try
    {
      stmt = connection.createStatement();
      connection.setAutoCommit(true);
      resultSet = stmt.executeQuery("SELECT MAX(" + idField + ") FROM " + table);
      connection.setAutoCommit(false);
      if (resultSet.next())
      {
        return idHandler.getCDOID(resultSet, 1);
      }

      return null;
    }
    catch (SQLException ex)
    {
      throw new DBException(ex);
    }
    finally
    {
      DBUtil.close(resultSet);
      DBUtil.close(stmt);
    }
  }
Comment 3 Eike Stepper CLA 2012-06-05 07:30:33 EDT
Moving all open bug reports to 4.1 because the release is very near and it's hghly unlikely that there will be spare time to address 4.0 problems.

Please make sure that your patches can be applied against the master branch and that your problem is not already fixed there!!!
Comment 4 Eike Stepper CLA 2012-08-14 22:53:46 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 5 Eike Stepper CLA 2012-10-17 08:17:31 EDT
(In reply to comment #2)
>     try
>     {
>       stmt = connection.createStatement();
>       connection.setAutoCommit(true);

Hmm, wouldn't it be better to do this in org.eclipse.emf.cdo.server.internal.db.DBStore.repairAfterCrash()?
Comment 6 Eike Stepper CLA 2012-10-18 10:18:29 EDT
This bug and bug 364809 are basically duplicates but they seem to suggest different solutions.
Comment 7 Eike Stepper CLA 2012-10-31 06:22:16 EDT
Fixed via bug 364809.

*** This bug has been marked as a duplicate of bug 364809 ***
Comment 8 Eike Stepper CLA 2013-06-27 04:00:39 EDT
Closing