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

Fix courier "request already started" bug #6651

Merged
merged 4 commits into from
Mar 25, 2016

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Mar 24, 2016

The current implementation of the SegmentedRequest doesn't mark the request started until after the fieldStats api provides an index list.

This means that if two courier fetch cycles start in close succession then the same request will be included in both, causing a "Unable to start request because it has already started" error to be thrown.

This protects against that by calling the super.start() method synchronously and then asynchronously populating the index queue. It feels wrong to me that the request is marked "started" before it's start() method is done, but the only other solution I have in mind requires that only one courier fetch cycle can initialize at a time (a much more impactful change).

Fixes #5828

this._all = queue.slice(0);

// Send the initial fetch status
this._reportStatus();

return super.start();
Copy link
Contributor

Choose a reason for hiding this comment

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

Moving this may be a problem. I'm not 100% on that, but I seem to remember there being a very specific reason why the parent constructor wasn't invoked until after the queue was created. Gross as hell though, and I really should have left a comment about it in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I went looking for the discussion we had about it, but I'm pretty sure it's just what I talked about in the last paragraph of my description:

It feels wrong to me that the request is marked "started" before it's start() method is done, but the only other solution I have in mind requires that only one courier fetch cycle can initialize at a time (a much more impactful change).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thankfully the AbstractRequest#start() method is pretty simple and really only exists for reporting purposes and to make sure that requests aren't being executed multiple times.

@epixa
Copy link
Contributor

epixa commented Mar 24, 2016

I updated the PR description to reference the ticket.

@rashidkpc rashidkpc assigned epixa and unassigned rashidkpc Mar 25, 2016
@rashidkpc
Copy link
Contributor

This LGTM. Assigning to @epixa to merge

@epixa epixa merged commit fe5ec6c into elastic:master Mar 25, 2016
elastic-jasper added a commit that referenced this pull request Mar 25, 2016
---------

**Commit 1:**
[courier/segmentedRequest] mark the request "started" synchronously

* Original sha: 8a49926
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:00Z

**Commit 2:**
[courier/fetch] detect aborted requests more agressively

* Original sha: c12f18d
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:46Z

**Commit 3:**
[courier/callClient] if there are no executable requests, do nothing

* Original sha: 8fef03b
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:36:18Z

**Commit 4:**
[courier/tests] updated test

* Original sha: 985f997
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T22:25:31Z
This was referenced Mar 28, 2016
elastic-jasper added a commit that referenced this pull request Mar 28, 2016
---------

**Commit 1:**
[courier/segmentedRequest] mark the request "started" synchronously

* Original sha: 8a49926
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:00Z

**Commit 2:**
[courier/fetch] detect aborted requests more agressively

* Original sha: c12f18d
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:46Z

**Commit 3:**
[courier/callClient] if there are no executable requests, do nothing

* Original sha: 8fef03b
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:36:18Z

**Commit 4:**
[courier/tests] updated test

* Original sha: 985f997
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T22:25:31Z
epixa added a commit that referenced this pull request Mar 28, 2016
---------

**Commit 1:**
[courier/segmentedRequest] mark the request "started" synchronously

* Original sha: 8a49926
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:00Z

**Commit 2:**
[courier/fetch] detect aborted requests more agressively

* Original sha: c12f18d
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:46Z

**Commit 3:**
[courier/callClient] if there are no executable requests, do nothing

* Original sha: 8fef03b
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:36:18Z

**Commit 4:**
[courier/tests] updated test

* Original sha: 985f997
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T22:25:31Z
spalger added a commit that referenced this pull request Mar 28, 2016
elastic-jasper added a commit that referenced this pull request Mar 28, 2016
---------

**Commit 1:**
[courier/segmentedRequest] mark the request "started" synchronously

* Original sha: 8a49926
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:00Z

**Commit 2:**
[courier/fetch] detect aborted requests more agressively

* Original sha: c12f18d
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:46Z

**Commit 3:**
[courier/callClient] if there are no executable requests, do nothing

* Original sha: 8fef03b
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:36:18Z

**Commit 4:**
[courier/tests] updated test

* Original sha: 985f997
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T22:25:31Z
epixa added a commit that referenced this pull request Mar 28, 2016
@epixa epixa added v4.5.2 and removed v4.5.1 labels May 14, 2016
@epixa epixa added v4.5.4 and removed v4.5.2 labels Jul 21, 2016
@spalger spalger deleted the fix/courier/requestAlreadyStarted branch October 18, 2019 17:38
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.

Fatal Error: Courier Fetch: Unable to start request because it has already started.
3 participants