Skip to content
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

[Transform] decouple task and indexer #48567

Merged
merged 20 commits into from
Nov 1, 2019

Conversation

hendrikmuhs
Copy link

@hendrikmuhs hendrikmuhs commented Oct 28, 2019

decouple TransformTask and ClientTransformIndexer. Interaction between the 2 classes are now moved into a context class which holds shared information.

relates #45369

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core (:ml/Transform)

@hendrikmuhs hendrikmuhs marked this pull request as ready for review October 28, 2019 13:50
@hendrikmuhs hendrikmuhs removed the WIP label Oct 28, 2019
@benwtrent benwtrent self-requested a review October 29, 2019 11:36
Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

Mostly minor things.

One overall question:

Why aren't indexerState and indexerPosition part of the context? Both the parent task and the internal indexer refer to them.

"task encountered more than " + transformTask.getNumFailureRetries() + " failures; latest failure: " + e.getMessage();
if (isIrrecoverableFailure(e) || failureCount.incrementAndGet() > context.getNumFailureRetries()) {
String failureMessage = isIrrecoverableFailure(e)
? "task encountered irrecoverable failure: " + e.getMessage()
Copy link
Member

Choose a reason for hiding this comment

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

if this is how our new formatting is (putting ? on the next line), I don't like it.

e);
if (handleCircuitBreakingException(e)) {
return;
if (shouldStopAtCheckpoint) {
Copy link
Member

Choose a reason for hiding this comment

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

Having this at the end of doSaveState does not make sense. This means that if shouldStopAtCheckpoint is true, then we will stop at the end of a doSaveState call. But, doSaveState can be called once we process 50 pages and is no indication of actually finishing a checkpoint or not.

In short, how do you know this is the doSaveState after a checkpoint has finished?

Copy link
Author

Choose a reason for hiding this comment

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

I am not aware that I changed the logic, maybe this is a unclean merge? Will check.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

@hendrikmuhs hendrikmuhs Oct 30, 2019

Choose a reason for hiding this comment

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

I had a look at #48591 again and compared the code paths. It should work again.

The merge problem was that I pulled from master when onStart/onFinish was already moved into the TransformIndexer class. git produced this weird line, actually it had it even twice.

I moved shouldStopAtCheckpoint into the context object, I am not fully satisfied how it gets set when a transform is loaded, but decided to keep this as a todo for later. This PR is already very complex.

// This indicates an early exit since no changes were found.
// So, don't treat this like a checkpoint being completed, as no work was done.
if (hasSourceChanged == false) {
listener.onResponse(null);
Copy link
Member

Choose a reason for hiding this comment

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

Unless there is another onFinish that I missed, it seems we are no longer stopping if shouldStopAtCheckpoint is true here. That is a problem in the following scenario:

  • Indexer kicked off to check for changes (state changed to Indexing from started)
  • While the state is Indexing somebody called _stop?wait_for_checkpoint=true
  • Stop sets wait_for_checkpoint to be true, and does not call stop (Indexer state is still INDEXING)
  • OnFinish is called with no changes and the indexer changes to started
  • Never stops even though wait_for_checkpoint is true.

Copy link
Author

Choose a reason for hiding this comment

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

good spot, the merge broke it.

@hendrikmuhs
Copy link
Author

Why aren't indexerState and indexerPosition part of the context? Both the parent task and the internal indexer refer to them.

Both are members of Async2PhaseIndexer, I therefore can't move it into context and I do not want to change Async2PhaseIndexer.

Having that said, there might be more stuff to be moved around, it's probably not perfect but in my opinion it's now less confusing and a cleaner structure. No cyclic dependency anymore.

@hendrikmuhs
Copy link
Author

hendrikmuhs commented Oct 30, 2019

run elasticsearch-ci/packaging-sample-matrix

@hendrikmuhs hendrikmuhs merged commit 56731d8 into elastic:master Nov 1, 2019
hendrikmuhs pushed a commit to hendrikmuhs/elasticsearch that referenced this pull request Nov 1, 2019
decouple TransformTask and ClientTransformIndexer. Interaction between the 2 classes are now moved into a context class which holds shared information.

relates elastic#45369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants