Skip to content

Commit

Permalink
Patch in the fix for IndexOutOfBoundException in BigQueueImpl
Browse files Browse the repository at this point in the history
The fix is described at bulldog2011#24
  • Loading branch information
tbye-pfp authored Aug 1, 2022
1 parent 6a8830a commit d466ef0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/org/kairosdb/bigqueue/BigQueueImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,14 @@ public CompletableFuture<byte[]> dequeueAsync() {
public void removeAll() throws IOException {
try {
queueFrontWriteLock.lock();
this.innerArray.removeAll();
// https://github.com/bulldog2011/bigqueue/issues/24
// 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();

IMappedPage queueFrontIndexPage = this.queueFrontIndexPageFactory.acquirePage(QUEUE_FRONT_PAGE_INDEX);
ByteBuffer queueFrontIndexBuffer = queueFrontIndexPage.getLocal(0);
queueFrontIndexBuffer.putLong(0L);
Expand Down

0 comments on commit d466ef0

Please sign in to comment.