Skip to content

[#2230] KahaDB dedicated cursor iterator#2231

Open
mattrpav wants to merge 4 commits into
apache:mainfrom
mattrpav:amq-gh-2230-dedicated-cursor-iterator
Open

[#2230] KahaDB dedicated cursor iterator#2231
mattrpav wants to merge 4 commits into
apache:mainfrom
mattrpav:amq-gh-2230-dedicated-cursor-iterator

Conversation

@mattrpav

@mattrpav mattrpav commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Validation steps:

  1. Checkout this branch
  2. Checkout first commit and build
  3. Run the unit test and observe 2 test failures against 2 control tests
  4. Checkout second commit and build
  5. Run the unit test and observe 4 test pass

@cshannon

Copy link
Copy Markdown
Contributor

I only glanced at this and haven't reviewed it but it sounds like the name should probably be IsolatedIterator vs DedicatedIterator as a better description of what's going on

@mattrpav mattrpav moved this from Backlog to In review in Apache ActiveMQ v6.3.0 Jul 18, 2026
@mattrpav

Copy link
Copy Markdown
Contributor Author

IsolatedIterator

'DedicatedItertor' was following the taxonomy of 'DedicatedCursor'. Are you suggesting a change to only the Iterator now, or go ahead and bite off changing both?

@cshannon

Copy link
Copy Markdown
Contributor

IsolatedIterator

'DedicatedItertor' was following the taxonomy of 'DedicatedCursor'. Are you suggesting a change to only the Iterator now, or go ahead and bite off changing both?

I forgot about the DedicatedCursor, I would keep both the same so it's clear and if there is no breaking change you could rename both. Isolated i think better describes what's really going on, but if it's going to cause problems we can just keep it as Dedicated

@mattrpav
mattrpav marked this pull request as ready for review July 20, 2026 17:06
@mattrpav
mattrpav force-pushed the amq-gh-2230-dedicated-cursor-iterator branch from d500651 to 7a4d037 Compare July 20, 2026 17:45

Iterator<Entry<Long, MessageKeys>> iterator(Transaction tx, MessageOrderCursor m) throws IOException{
return new MessageOrderIterator(tx,m,this);
return new MessageOrderIterator(tx,m,this,true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to remember the original PR, but I feel like we should only need 2 methods and not 4.

Shouldn't we only ever need to pass in a new MessageOrderCursor when we want to be isolated? For some reason the recovery() method was updated to use new MessageOrderCursor() but i don't see why that was changed in the original PR. That method already resets it here

I would think we would only two variations of the iterator...one that tracks state (including the last used keys) and uses the MessageOrderCursor that is part of the definition and one that is completely isolated but maybe I am missing something.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we update the recovery() method to not track the last keys either. Either way, it seems like we should either be isolated or not and the 4 methods includes a weird hybrid option of partial isolation

@cshannon cshannon Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look closer and there are 2 spots that should be be using the isolated cursor, the recover() method and also the recoverExpired() methods. Also, both methods have a reset call that can go away, for example:

The reason it doesn't break is those methods are used exclusively for Topics and it doesn't interfere with the subscription recovery as each call to recoverNext() for a sub resets the cursor to the correct offset anyways.

Queues and durable subscriptions exclusively use the recoverNext() methods to keep track of state.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change applied here 77de343

final boolean trackLastKeys;

MessageOrderIterator(Transaction tx, MessageOrderCursor m, MessageOrderIndex messageOrderIndex) throws IOException {
MessageOrderIterator(Transaction tx, MessageOrderCursor m, MessageOrderIndex messageOrderIndex, boolean trackLastKeys) throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a single MessageOrderIterator with lots of args I am wondering if it makes sense to just have two impls.

We could rename MessageOrderIterator to IsolatedMessageOrderIterator that does no tracking (uses a new MessageOrderIndex() and doesn't track keys), and then extend that class with MessageOrderIterator that tracks keys and uses the shared MessageOrderCursor.

This is just an idea I had, I'm not sure if it would make it better or worse without trying it compared to constructor orgs and a single impl

@mattrpav mattrpav Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest commit 68eea73 applies these changes

mattrpav added 2 commits July 20, 2026 16:47
…rIterator and no longer call resetCursorPosition()
@mattrpav
mattrpav requested a review from cshannon July 20, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants