Skip to content

Future created with Future.delayed() sometimes fails to execute in a timely fashion #22626

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

Closed
stereotype441 opened this issue Mar 2, 2015 · 6 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@stereotype441
Copy link
Member

In the analysis server, we sometimes schedule our analysis tasks using an ordinary future:

new Future(performOperation);

and we sometimes schedule them using a very short delay:

new Future.delayed(new Duration(milliseconds: 1), performOperation)

(The short delay prevents these tasks from taking precedence over other events in the event loop which we want to be handled in a timely fashion, such as requests from the client).

We have recently observed that sometimes when an event is scheduled using Future.delayed(), it fails to execute and the process goes idle. It is as though the event loop goes into a "stuck" state where it has forgotten that an event was scheduled. This causes the appearance to the user that analysis is taking forever to complete, when in fact no analysis is being performed. Further requests from the analysis server's client (which arrive via stdin) do not "un-stick" the event, however modifying files in the filesystem (which are being watched using the "watcher" package) seems to cause enough of a kick to get the future to fire.

Anecdotally, it appears that this may be triggered by the following sequence of events: 1. task is scheduled using Future.delayed(), 2. task takes a long time to execute (~800ms), 3. task schedules itself to run again using Future.delayed()--this second future doesn't fire. However, there must be some other factors at play (microtasks or other pending events, perhaps?), because we've been unable to find a short program that reproduces the bug.

@iposva-google
Copy link
Contributor

When was the first time you saw Future.delayed not being scheduled?

@stereotype441
Copy link
Member Author

It's difficult to say. Konstantin first noticed analysis getting "stuck" about 2 weeks ago, but we weren't able to track it down to Future.delayed() until about 2 days ago. So it's likely that the bug is a few weeks old.

However we've recently fixed one other bug that has similar symptoms--see issue #22555 (Issue #22555 also made analysis server seem to be "stuck", but it was due to analysis getting into an infinite loop rather than going idle and failing to dispatch a future). So it's also possible that the problem we're seeing now started more recently, and we only think it's a few weeks old because it's similar to past problems.

@iposva-google
Copy link
Contributor

Fixed with r44191.


Added Fixed label.

@sethladd
Copy link
Contributor

sethladd commented Mar 3, 2015

Thanks!

@whesse
Copy link
Contributor

whesse commented May 27, 2015

The regression test for this is failing on MIPS hardware, because it is slow and can be heavily overloaded. I think the regression test /lib/async/timer_regress22626_test.dart has a clear failure mode when the system is unresponsive for more than 50 ms, and so I am skipping it on this system.

@stereotype441 stereotype441 added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels May 27, 2015
@kasperl
Copy link

kasperl commented Jan 4, 2017

The test case added looks flaky by design as noted by @whesse. Filed issue #28254 to track this.

kasperl pushed a commit that referenced this issue Jan 4, 2017
Expanding the MIPS-specific flaky marker in the status file to cover all architectures after seeing this on debug-x64 too.

See #28254 and the older
#22626.

[email protected]
BUG=

Review-Url: https://codereview.chromium.org/2615593002 .
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

5 participants