HelixNetwork / pendulum

Pendulum is a distributed messaging protocol that enables globally available tamper proof timestamps :hourglass_flowing_sand:
https://dev.hlx.ai
Other
10 stars 6 forks source link

Dev fix db lock #255

Closed spangin closed 4 years ago

dnck commented 4 years ago

I noticed the other day that I could not read the spent-addresses-db because it had a LOCK on it. Does this PR fix that?

I tried to cherry pick both commit hashes. Things seemed ok until I stopped and restarted the node. Then, I got the following message in stderr:

12/03 17:24:46.167 [Latest Solid Milestone Tracker] ERROR n.h.p.s.m.i.LatestSolidMilestoneTrackerImpl - error while updating the solid milestone
net.helix.pendulum.service.ledger.LedgerException: unexpected error while restoring the ledger state
    at net.helix.pendulum.service.ledger.impl.LedgerServiceImpl.restoreLedgerState(LedgerServiceImpl.java:91) ~[pendulum-1.0.6.jar:na]
    at net.helix.pendulum.service.milestone.impl.LatestSolidMilestoneTrackerImpl.latestSolidMilestonesTrackerThread(LatestSolidMilestoneTrackerImpl.java:216) ~[pendulum-1.0.6.jar:na]
    at net.helix.pendulum.utils.thread.BoundedScheduledExecutorService.lambda$wrapTask$6(BoundedScheduledExecutorService.java:749) ~[pendulum-1.0.6.jar:na]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_171]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[na:1.8.0_171]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_171]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[na:1.8.0_171]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_171]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_171]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_171]
Caused by: net.helix.pendulum.service.milestone.MilestoneException: unexpected error while trying to find the latest processed solid milestone in the database
    at net.helix.pendulum.service.milestone.impl.MilestoneServiceImpl.findLatestProcessedSolidRoundInDatabase(MilestoneServiceImpl.java:131) ~[pendulum-1.0.6.jar:na]
    at net.helix.pendulum.service.ledger.impl.LedgerServiceImpl.restoreLedgerState(LedgerServiceImpl.java:86) ~[pendulum-1.0.6.jar:na]
    ... 9 common frames omitted
Caused by: java.lang.NullPointerException: null
    at net.helix.pendulum.service.milestone.impl.MilestoneServiceImpl.findLatestProcessedSolidRoundInDatabase(MilestoneServiceImpl.java:125) ~[pendulum-1.0.6.jar:na]
    ... 10 common frames omitted
spangin commented 4 years ago

I noticed the other day that I could not read the spent-addresses-db because it had a LOCK on it. Does this PR fix that?

Yes. In this fix RocksDBPersistenceProvider instance is created and closed correctly. So the DB can be used again.

dnck commented 4 years ago

I noticed the other day that I could not read the spent-addresses-db because it had a LOCK on it. Does this PR fix that?

Yes. In this fix RocksDBPersistenceProvider instance is created and closed correctly. So the DB can be used again.

Hmmmm.... when I cherry-picked the commits, I actually had problems (the output is above). I did cherry-pick the commits out of order. Might that have been my problem?

Also, if you have some chance, I made some changes to the SpentAddressesProviderImpl in my PR 247. Is there any possibility of merging these into your branch?

spangin commented 4 years ago

lso, if you have some chance, I made some changes to the SpentAddressesProviderImpl in my PR 247. Is there any possibility of merging these into your branch?

My fix is not big, so I'll be able to resolve the conflicts if your PR be approved firstly. The 2nd way is I can add the code to your branch. It will not take much time.