Skip to content

Conversation

@dnhatn
Copy link
Member

@dnhatn dnhatn commented Jul 10, 2018

This change introduces a new primitive method which supports undoing a single operation. This utility will be used to build Lucene rollback.

This change introduces a new primitive method which supports
undoing a single operation. This utility will be used to build Lucene rollback.
@dnhatn dnhatn added >feature :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. labels Jul 10, 2018
@dnhatn dnhatn requested review from bleskes and s1monw July 10, 2018 01:49
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@dnhatn
Copy link
Member Author

dnhatn commented Jul 10, 2018

/cc @ywelsch

@dnhatn dnhatn mentioned this pull request Jul 10, 2018
11 tasks
@dnhatn
Copy link
Member Author

dnhatn commented Jul 11, 2018

@bleskes I've updated the PR to introduce maybeRollback method. Can you please have a look? Thank you!

Copy link
Contributor

@bleskes bleskes left a 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;
Copy link
Contributor

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.

Copy link
Member Author

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());
Copy link
Contributor

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());
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@jpountz I see @s1monw making a reader cache for SoftDeletesDirectoryReaderWrapper. However, I could not create a instance of CacheKey because its constructor is not public.

Copy link
Member Author

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.

Copy link
Contributor

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()) {
Copy link
Contributor

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.

@dnhatn dnhatn requested review from bleskes and jpountz July 18, 2018 18:59
@dnhatn
Copy link
Member Author

dnhatn commented Jul 18, 2018

@bleskes and @jpountz I've updated the PR, can you please give it another go? Thank you!

@bleskes
Copy link
Contributor

bleskes commented Jul 21, 2018

@dhnat and I discussed some more potential simplifications via another channel.

@jasontedor
Copy link
Member

@dnhatn I think that we can close this PR for now?

@dnhatn
Copy link
Member Author

dnhatn commented Sep 2, 2018

@jasontedor Yes.
I am closing this as we are going to implement a commit-based rollback.

@dnhatn dnhatn closed this Sep 2, 2018
@dnhatn dnhatn deleted the rollback-single-op branch September 2, 2018 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. >feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants