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

Getting an IndexOutOfBoundException when IBigQueue.peek #24

Open
gimantha opened this issue Aug 2, 2016 · 6 comments
Open

Getting an IndexOutOfBoundException when IBigQueue.peek #24

gimantha opened this issue Aug 2, 2016 · 6 comments

Comments

@gimantha
Copy link

gimantha commented Aug 2, 2016

Hi @bulldog2011, @TobiasMende , @wjw465150 , @illya13

We use bigqueue implementation to buffer incoming data in our code base. We use a background thread to consume the queue (every 1.5 seconds). Recently we did some load test and published some data. We could observe the following exception occurred when we restart our server.

[2016-08-02 10:37:28,676] ERROR {org.wso2.carbon.analytics.dataservice.core.indexing.AnalyticsDataIndexer} - Error in processing index batch operations: null
java.lang.IndexOutOfBoundsException
at com.leansoft.bigqueue.BigArrayImpl.validateIndex(BigArrayImpl.java:458)
at com.leansoft.bigqueue.BigArrayImpl.get(BigArrayImpl.java:399)
at com.leansoft.bigqueue.BigQueueImpl.peek(BigQueueImpl.java:144)
at org.wso2.carbon.analytics.dataservice.core.indexing.LocalIndexDataStore$LocalIndexDataQueue.peekNext(LocalIndexDataStore.java:269)
I would like to know, under what conditions, the above exception can be thrown?
We use the bigqueue implementation here[1]

Appreciate your help!

[1] https://github.com/wso2/carbon-analytics/blob/master/components/analytics-core/org.wso2.carbon.analytics.dataservice.core/src/main/java/org/wso2/carbon/analytics/dataservice/core/indexing/LocalIndexDataStore.java

Thanks,

@jsabin
Copy link

jsabin commented Jun 1, 2018

Seeing the same problem. Anyone know the cause or how to prevent this? Seen this on version 0.7.0.

java.lang.IndexOutOfBoundsException
        at com.leansoft.bigqueue.BigArrayImpl.validateIndex(BigArrayImpl.java:458)
        at com.leansoft.bigqueue.BigArrayImpl.get(BigArrayImpl.java:399)
        at com.leansoft.bigqueue.BigQueueImpl.dequeue(BigQueueImpl.java:104)
        at com.proofpoint.queue.FileBackedQueue.dequeue(FileBackedQueue.java:183)

@MrWickedG
Copy link

MrWickedG commented Nov 5, 2018

Does anybody have any solution for this issue? Please let me know
@jsabin @gimantha

@gimantha
Copy link
Author

gimantha commented Nov 5, 2018 via email

@MrWickedG
Copy link

@gimantha We create/delete 32 mb page files every several minutes, so i'd say its quite big while maintaining close to a hundred of queues. This error is quite occasional but we did not find a solution for it yet.

Did you solve it somehow?

@gimantha
Copy link
Author

gimantha commented Nov 5, 2018 via email

@yoonforh
Copy link

yoonforh commented Jun 15, 2020

i found the problem in BigQueueImpl.java.

in removeAll method of the BigQueueImpl.java
current code is

            queueFrontWriteLock.lock();
            this.innerArray.removeAll();
            this.queueFrontIndex.set(0L);

i think the code should be rearranged like this

            queueFrontWriteLock.lock();
            // if some thread access queueFrontIndex.get() without queueFrontWriteLock, 
            // then this could be a problem.
            // you should clear queueFrontIndex first (peek or dequeue)
            // before remove all the innerArray
            this.queueFrontIndex.set(0L);
            this.innerArray.removeAll();

this code can cause "java.lang.IndexOutOfBoundsException: null" in peek() method and in dequeue() method.
i found the dequeue() method scenario can happen when the gc() method is invoked at the time.

if some thread access queueFrontIndex.get() without queueFrontWriteLock, then this could be a problem.
if old version of removeAll() method is called and gc() is called after innerArray.removeAll() and before queueFrontIndex.set(0), then
queueFrontIndex will return some bigger value and removeBeforeIndex will be called on that index.
and later, dequeue will be called and queueFrontIndex will be zero but the innerArray.arrayTailIndex will be set to the some positive value.
yes, innerArray.validateIndex(0) will cause a problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants