Closed Bug 1897264 Opened 2 months ago Closed 1 month ago

Add a `SuggestStore.interruptEverything` API to interrupt ingestions

Categories

(Application Services :: Suggest, task)

Tracking

(firefox127 wontfix, firefox128 fixed)

RESOLVED FIXED
128 Branch
Tracking Status
firefox127 --- wontfix
firefox128 --- fixed

People

(Reporter: lina, Assigned: bdk)

References

Details

(Whiteboard: disco)

Attachments

(2 files)

SuggestStore.interrupt() currently only interrupts reads. This is by design, so that apps can cancel ongoing queries as the user types, and free up the reader connection for the user's latest input.

We currently don't have an analogue for interrupting ingestions or writes, which is a problem if we're backgrounded on iOS (or the user closes Firefox, in the case of Desktop), and the OS tells us to wrap up our work. It's still not possible to interrupt network requests with Viaduct, but that's OK; we can still check and interrupt the ingestion after the network request completes.

I'm thinking that interruptEverything could be this analogue, and interrupt writes as well as reads.

In the worst case of an empty or rechunked database, if we're making 80 network requests for an ingestion, and the OS tells us to stop when we're in the middle of request 5, we can interrupt ingestion after request 5 finishes, without having to wait for the remaining 75 requests to finish.

On the iOS side, we can call interruptEverything from our background ingestion task's "expiration handler". That handler gets called whenever iOS wants to tell us to wrap up.

On Desktop, we can call interruptEverything at shutdown.

(I'm not tied to the interruptEverything name at all; I just wanted to make it something long and vaguely awkward, to gently discourage consumers from using it incorrectly 😅 Unless the app is shutting down, it shouldn't need to call interruptEverything).

Whiteboard: disco

What do you think of using the shutdown function for this? That was designed for this use-case.

Calling shutdown would also interrupt all other components with interruption support. I think that's okay, maybe good. What do you think?

Flags: needinfo?(lina)

Oh, cool; that's a great system!

I think I'm a little nervous about making the Suggest background task handler interrupt all components with interruption support, though. iOS can schedule background tasks separately, with different time slices for each—e.g., I think it's possible for the sync1 and sync2 tasks to keep running even if ingest expires, or even for sync{1, 2} to run concurrently with ingest. I'm not sure that we'd want ingest's expiration handler to also shut down sync1 and sync2.

WDYT?

Flags: needinfo?(lina) → needinfo?(bdeankawamura)

That makes sense to me. Also shutdown causes all future operations to be interrupted as well, which doesn't seem right for this case. Sounds like we do want an interruptEverything method rather than shutdown.

Flags: needinfo?(bdeankawamura)

One more thought here, maybe it's better to define an interruptIngestion method that doesn't interrupt in-progress reads. For this use-case I think it's the same, but maybe some consumers will want to interrupt the ingestion task because it's taking too long, but don't want to interrupt pending reads.

Flags: needinfo?(lina)

That sounds good to me, too! The expiration handler can call both interrupt() and interruptIngestion(), and consumers that only want to interrupt the latter can do just that.

Flags: needinfo?(lina)
Blocks: 1895110

Comment on attachment 9404497 [details] [review]
[mozilla/application-services] Bug 1897264 - interruption support for ingestion (backport #6246) (#6256)

Beta/Release Uplift Approval Request

  • User impact if declined: Users enrolled in the Enhanced Cross-Platform Suggest experiment in Firefox for iOS could experience increased app relaunch times, due to the system force-stopping Firefox because the background task for downloading new suggestions can't be interrupted. This App Services PR adds the necessary API for interrupting downloads; there's a separate Firefox for iOS PR that adopts the API.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This is a new API that has automated test coverage, and has been landed and tested in Firefox for iOS 128.
  • String changes made/needed: None
  • Is Android affected?: No
Attachment #9404497 - Flags: approval-mozilla-beta?
Assignee: nobody → lina
Assignee: lina → bdeankawamura

Thanks for merging the uplift PR, Pascal!

When you have some time, would you mind cutting an App Services 127.0.1 release with it, please?

Flags: needinfo?(pascalc)

(In reply to Lina Butler [:lina] from comment #10)

Thanks for merging the uplift PR, Pascal!

When you have some time, would you mind cutting an App Services 127.0.1 release with it, please?

This is done https://github.com/mozilla/application-services/releases/tag/v127.0.1

Flags: needinfo?(pascalc)
Attachment #9404497 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

https://github.com/mozilla/application-services/commit/8bd7ba4ea4dd4454420ca1eb87558c3c06d72162 landed on main but thr bugzilla integration didn't update the bug flags and closed the bugs.
I am resolving the bug as fixed and updating the 128 flag.

Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED

Vendored in bug 1899410

Target Milestone: --- → 128 Branch
Depends on: 1899410

This wasn't uplifted to Firefox 127

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: