-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add primitive method allows rollback a single operation #31910
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
Conversation
This change introduces a new primitive method which supports undoing a single operation. This utility will be used to build Lucene rollback.
|
Pinging @elastic/es-distributed |
|
/cc @ywelsch |
|
@bleskes I've updated the PR to introduce |
bleskes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I post my comments so far. @dnhatn and I discussed some changes in another channel.
| * | ||
| * @return {@code true} if there is a difference between the colliding operation and the new operation | ||
| */ | ||
| public abstract boolean maybeRollback(MapperService mapperService, Engine.Operation newOp) throws IOException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be private / package private. It can also be an InternalEngine thing. It's an implementation detail IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we would use this from IndexShard. I removed this method.
| long collidingTerm = Lucene.readNumericDV(collidingSegment.reader(), SeqNoFieldMapper.PRIMARY_TERM_NAME, collidingDocId); | ||
| if (collidingTerm == newOp.primaryTerm()) { | ||
| // matches with the existing doc | ||
| localCheckpointTracker.markSeqNoAsCompleted(newOp.seqNo()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be done here - it's part of the indexing logic.
| return new SubReaderWithLiveDocs(leaf, null, leaf.maxDoc()); | ||
| } | ||
| int rollbackCount = 0; | ||
| FixedBitSet liveDocs = new FixedBitSet(leaf.maxDoc()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be cached somehow? /cc @jpountz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am exploring a cache of liveDocs using coreCacheHelper and docValuesGeneration as key. It looks good, but I need to make sure that it works correctly and write some tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't need to create cache keys and could directly use LeafReader instances as cache keys.
| searcher.setQueryCache(null); | ||
| final FieldsVisitor fields; | ||
| final Query currentVersionQuery = LongPoint.newExactQuery(SeqNoFieldMapper.NAME, newOp.seqNo()); | ||
| try (ReleasableLock ignored = readLock.acquire()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be done on the top level try no? before we call acquireSearcher.
|
@dhnat and I discussed some more potential simplifications via another channel. |
|
@dnhatn I think that we can close this PR for now? |
|
@jasontedor Yes. |
This change introduces a new primitive method which supports undoing a single operation. This utility will be used to build Lucene rollback.