Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE due to incorrect condition in java #9169

Closed
PhantomYdn opened this issue Mar 17, 2020 · 4 comments
Closed

NPE due to incorrect condition in java #9169

PhantomYdn opened this issue Mar 17, 2020 · 4 comments
Assignees
Labels
Milestone

Comments

@PhantomYdn
Copy link
Contributor

PhantomYdn commented Mar 17, 2020

Hello,

Please check the following 2 lines of code

As you can see: you can get easily NPE if walCountersHolder==null (our case).

Full exception:

Uncaught exception in thread 'OrientDB Write Cache Flush Task (Orienteer)'
java.lang.NullPointerException
        at com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic.makeSnapshotIfNeeded(OSessionStoragePerformanceStatistic.java:1236)
        at com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic.stopWriteCacheFlushTimer(OSessionStoragePerformanceStatistic.java:716)
        at com.orientechnologies.orient.core.storage.cache.local.OWOWCache$PeriodicFlushTask.run(OWOWCache.java:1931)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
@PhantomYdn
Copy link
Contributor Author

Btw, NPE is also possible if monitoring was not started for some reason (exception and etc), but stopMonitoring has been invoked due to the following construction:

public void stopMonitoring() {
switchLock.acquireWriteLock();
try {
enabled = false;
final PerformanceCountersHolder countersHolder = ComponentType.GENERAL.newCountersHolder();
final Map<String, PerformanceCountersHolder> componentCountersHolder = new HashMap<>();
WritCacheCountersHolder writCacheCountersHolder = deadThreadsStatistic.writCacheCountersHolder;
StorageCountersHolder storageCountersHolder = deadThreadsStatistic.storageCountersHolder;
WALCountersHolder walCountersHolder = deadThreadsStatistic.walCountersHolder;

I think it will be safer if stopMonitoring() will exit immediately if monitoring was not enabled.

@PhantomYdn
Copy link
Contributor Author

I'm sorry, but it seems that OPerformanceStatisticManager was not fully tested, because due to mentioned NPE - it's not possible to get OWOWCache$PeriodicFlushTask running - it stops execution after first Exception (btw - why? Critical things, imho, should be retryable) - so if performance monitoring was started - WOW Cache stops immediately flushing. Am I missing something?

@tglman tglman added the bug label Jun 1, 2020
@tglman tglman added this to the 3.1.x milestone Jun 1, 2020
andrii0lomakin added a commit that referenced this issue Jun 12, 2020
@andrii0lomakin
Copy link
Member

Fixed

@PhantomYdn
Copy link
Contributor Author

Nice fix;) Thank you!

@tglman tglman modified the milestones: 3.1.x, 3.1.16 Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants