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

TaskInstance '__DS_COPY_TASK_RUNNER__' was canceled because it belongs to a 'drop' Task that was already running. #7

Open
songoo opened this issue Aug 30, 2017 · 10 comments

Comments

@songoo
Copy link

songoo commented Aug 30, 2017

Hello.

I am using ember-data-copyable (0.2.1) to copy models, its very cool! And had no problems till today :( when I tried to copy same model in multiple times.

I have Promise.all(promises), in every of that promises I copy one or more models, but those are always the same models for all promises.

For example, I have 3 models (taskAsignments) , and I want copy all 3 of them in for example 6 promises.

What I encounter is, that all 3 models are copied in firstProcessedPromise and will fail in all other (five) promises with message :

TaskCancelation: TaskInstance 'DS_COPY_TASK_RUNNER' was canceled because it belongs to a 'drop' Task that was already running. For more information, see: http://ember-concurrency.com/#/docs/task-cancelation-help

I tried to rewrite Promise.all with reduce, so all 6 promises would be called in synchronized way, but result was same sadly. I also tried deep and not deep .copy with same result.

If possible please advice if have any idea.

@songoo
Copy link
Author

songoo commented Aug 30, 2017

I tried to replace .copy with manual (create record + calling all setters) copping and it went with no error. Also tried to get some info from ember slack, here is response, but not sure if it helps :

it’s hard to say without seeing some of the code, but that’s an error that will result from a promise rejection after a task instance has been coerced to a promise (usually by calling .then() or .catch() from a task instance, or by passing the task instance to something like an RSVP.hash or returning it from a route lifecycle hook).
this is mentioned in the docs here: http://ember-concurrency.com/api/global.html#didCancel

@roscorcoran
Copy link

I have this issue to when attempting to copy 2+ of the same model at once. Seems to be that only the last scheduled copy is performed all other copies are cancelled with the error outlined above.

@offirgolan
Copy link
Owner

Are you guys trying to copy the same model instance multiple times or are you copying different instances of the same model type?

@songoo
Copy link
Author

songoo commented Oct 9, 2017

Hi.
"same model instance multiple times", yes i get one assigment from database, then run 3 promises in same time and each of them will try to make its own copy of that exact assigment.

@offirgolan
Copy link
Owner

offirgolan commented Oct 9, 2017

Makes sense. The copy task runner has a drop concurrency task policy. That means it will only execute the first request and ignore the rest until it's done running.

I need to investigate other concurrency policies before just removing this one due to unforeseen implications. In the mean time, you guys will need to chain your requests.

async copyModels(model) {
  await model.copy();
  await model.copy();
  await model.copy();
}

@songoo
Copy link
Author

songoo commented Oct 9, 2017

I also tried synchronous promises(with reduce), it did not help (and i was sure it will) .

@offirgolan
Copy link
Owner

Hmmmm thats pretty odd. I'll investigate this further in the next week or two. Pretty swamped at the moment.

@donaldwasserman
Copy link

donaldwasserman commented Mar 21, 2018

@offirgolan Would you be willing to entertain a PR that makes it possible to allow a configurable set of concurrency options?

Something like:

model.copy({concurrencyPolicy: 'keepLatest'}) //because i can't spell Enqueue

I'm not familiar enough with the guts of EC to understand if you can dynamically apply .drop or whatever, but on the mixin side we could add a different layer of abstraction to do like

[COPY_TASK_<TYPE>]: task(function*() { return this.get('COPY_TASK').perform(options)).<TYPE>()

@offirgolan
Copy link
Owner

@donaldwasserman I would if there was a decent way of doing this. I'd rather not bomb the model's proto with a bunch of copy tasks for each concurrency policy.

ping @machty any thoughts on how I can support something like this?

@miguelcobain
Copy link
Collaborator

I think we shouldn't enforce any kind of concurrency policy ourselves and leave that choice to the user.

@offirgolan do you recall the reason to set the copy task concurrency policy to drop?

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

No branches or pull requests

5 participants