Skip to content

Commit

Permalink
Merge pull request #1 from tbye-pfp/patch-1
Browse files Browse the repository at this point in the history
Patch in the fix for IndexOutOfBoundException in BigQueueImpl
  • Loading branch information
brianhks authored Aug 2, 2022
2 parents 6a8830a + d466ef0 commit 87d302d
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 87d302d

Please sign in to comment.