[ 
https://issues.apache.org/jira/browse/DERBY-2074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12721736#action_12721736
 ] 

Knut Anders Hatlen commented on DERBY-2074:
-------------------------------------------

It looks like the problem is that TopService.bootModule() adds the new module 
to the vector moduleInstances before it boots the module. So when another 
thread concurrently checks if the module is available, it finds it in 
moduleInstances and uses it before it is properly initialized.

I thought swapping the order (boot first, then add to the vector) was a 
possible solution, but that resulted in lots of assert failures during boot.

All the traversal of moduleInstances is synchronized on the TopService 
instance, except the code that adds and boots the module. If that code is moved 
inside one of the synchronized blocks, the NPE goes away. There may be a good 
reason why that code is not synchronized, but I cannot find anything about it 
in the comments. I'll investigate more.

> Several times exception from derby implementation was thrown (were unable to 
> eproduce and check if it caused by any our work)
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-2074
>                 URL: https://issues.apache.org/jira/browse/DERBY-2074
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.1.3.1
>         Environment: WinXP Professional, Java 1.5.0_06
>            Reporter: Kovylin Alexandr
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: LoadSorter.java
>
>
> 12:34:45,323 ERROR [pool-1-thread-3] history.helpers.HistoryDataAccessHelper 
> - failed to read measurements, filter = (fromTime=Mon Nov 06 12:34:00 MSK 
> 2006, toTime=Mon Nov 13 12:34:00 MSK 2006, , properties=2-6-2-value) 
> org.springframework.jdbc.UncategorizedSQLException: 
> PreparedStatementCallback; uncategorized SQLException for SQL [SELECT 
> COUNT(DISTINCT sshis.measurement_time) FROM sshis_property_measurement sshis 
> INNER JOIN sstmp_filter_3 filtertbl ON sshis.property_id = 
> filtertbl.property_id WHERE sshis.measurement_time >= ? AND 
> sshis.measurement_time < ?]; SQL state [XJ001]; error code [0]; Java 
> exception:':
>  java.lang.NullPointerException'.; nested exception is
> org.apache.derby.impl.jdbc.EmbedSQLException: Java exception: ': 
> java.lang.NullPointerException'.
> java.lang.NullPointerException
>         at java.util.Hashtable.put(Unknown Source)
>         at 
> org.apache.derby.impl.store.access.RAMAccessManager.registerAccessMethod(Unknown
>  Source)
>         at 
> org.apache.derby.impl.store.access.RAMAccessManager.findMethodFactoryByImpl(Unknown
>  Source)
>         at 
> org.apache.derby.impl.store.access.RAMTransaction.createSort(UnknownSource)
>         at 
> org.apache.derby.impl.sql.execute.DistinctScalarAggregateResultSet.loadSorter(Unknown
>  Source)
>         at 
> org.apache.derby.impl.sql.execute.DistinctScalarAggregateResultSet.openCore(Unknown
>  Source)
>         at 
> org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.openCore(Unknown 
> Source)
>         at 
> org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.open(Unknown Source)
>         at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown 
> Source)
>         at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown 
> Source)
>         at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown 
> Source)
>         at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeQuery(Unknown Source)
>         at 
> org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:535)
>         at 
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:476)
>         at 
> org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:528)
>         at 
> org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:561)
>         at 
> org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:579)
>         at 
> org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:589)
>         at 
> org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:619)
>         at 
> org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:629)
>         at 
> org.springframework.jdbc.core.JdbcTemplate.queryForInt(JdbcTemplate.java:656)
>         at 
> com.meshnetics.wsn.ctrl.dispatcher.services.history.helpers.MeasurementsSaveGetHelper.getMeasurements(MeasurementsSaveGetHelper.java:81)
>         at 
> com.meshnetics.wsn.ctrl.dispatcher.services.history.helpers.HistoryDataAccessHelper$7.doInTransaction(HistoryDataAccessHelper.java:315)
>         at 
> com.meshnetics.wsn.ctrl.dispatcher.services.history.helpers.HistoryDataAccessHelper$7.doInTransaction(HistoryDataAccessHelper.java:314)
>         at 
> org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:117)
>         at 
> com.meshnetics.wsn.ctrl.dispatcher.services.history.helpers.HistoryDataAccessHelper.getMeasurements(HistoryDataAccessHelper.java:313)
>         at 
> com.meshnetics.wsn.ctrl.dispatcher.services.history.asyncread.MeasurementsReadTask.executeTask(MeasurementsReadTask.java:127)
>         at 
> com.meshnetics.wsn.ctrl.dispatcher.services.history.asyncread.MeasurementsReadTask.run(MeasurementsReadTask.java:97)
>         at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
>         at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
>         at java.util.concurrent.FutureTask.run(Unknown Source)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown 
> Source)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>         at java.lang.Thread.run(Unknown Source)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to