Akila created STRATOS-1565:
------------------------------

             Summary: Fix registry transactions exception handling
                 Key: STRATOS-1565
                 URL: https://issues.apache.org/jira/browse/STRATOS-1565
             Project: Stratos
          Issue Type: Bug
    Affects Versions: 4.1.2
            Reporter: Akila
             Fix For: 4.1.3


When performing Registry transactions, "beginTransaction" and 
"commitTransaction" methods should always be in a try block and 
RegistryException should be caught and rolled back by calling 
"rollbackTransaction" method. "rollbackTransaction" should also be in another 
try block and rollback exception should be properly logged.

For eg:

try {
            registryService.beginTransaction();
            registryService.delete(resourcePath);
            registryService.commitTransaction();
        } catch (RegistryException e) {
            try {
                registryService.rollbackTransaction();
            } catch (RegistryException e1) {
                if (log.isErrorEnabled()) {
                    log.error("Could not rollback transaction", e1);
                }
            }
            String message = "Could not delete resource at " + resourcePath;
            throw new AutoScalerException(message, e);
        }

Buggy registry operations could result in unreleased locks. Following error was 
observed due to this issue.

INFO - [2015-09-14 06:40:49,535] ERROR 
{org.wso2.carbon.registry.core.jdbc.dao.JDBCResourceDAO} -  Failed to check the 
existence of the resource /_system/governance/mock.iaas/instances. Timeout 
trying to lock table "REG_RESOURCE"; SQL statement:
INFO - SELECT REG_VERSION FROM REG_RESOURCE WHERE REG_PATH_ID=? AND REG_NAME=? 
AND REG_TENANT_ID=? [50200-140]
INFO - org.h2.jdbc.JdbcSQLException: Timeout trying to lock table 
"REG_RESOURCE"; SQL statement:
INFO - SELECT REG_VERSION FROM REG_RESOURCE WHERE REG_PATH_ID=? AND REG_NAME=? 
AND REG_TENANT_ID=? [50200-140]
INFO -  at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
INFO -  at org.h2.message.DbException.get(DbException.java:167)
INFO -  at org.h2.message.DbException.get(DbException.java:144)
INFO -  at org.h2.table.RegularTable.doLock(RegularTable.java:466)
INFO -  at org.h2.table.RegularTable.lock(RegularTable.java:404)
INFO -  at org.h2.table.TableFilter.lock(TableFilter.java:139)
INFO -  at org.h2.command.dml.Select.queryWithoutCache(Select.java:554)
INFO -  at org.h2.command.dml.Query.query(Query.java:241)
INFO -  at org.h2.command.CommandContainer.query(CommandContainer.java:80)
INFO -  at org.h2.command.Command.executeQuery(Command.java:132)
INFO -  at 
org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:96)
INFO -  at 
org.wso2.carbon.registry.core.jdbc.dao.JDBCResourceDAO.getVersion(JDBCResourceDAO.java:197)
INFO -  at 
org.wso2.carbon.registry.core.jdbc.dao.JDBCResourceDAO.resourceExists(JDBCResourceDAO.java:147)
INFO -  at 
org.wso2.carbon.registry.core.jdbc.dao.JDBCResourceDAO.resourceExists(JDBCResourceDAO.java:156)
 



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

Reply via email to