-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Entities can be loaded half-way while being updated #6232
Comments
@getodk/testers are you able to investigate this and see if you can create problems by updating forms (with changes to entities) during form entry on |
@getodk/testers any update of this? |
If an entity update/follow-up form is opened the entities in the opened form don't change after match exactly (adding some entities). The thing I'm going to explore are drafts after match exactly cause the changes in entities appear there. I open a follow-up form wait for match exactly, save the form as draft. When I open the draft there are new entities/ changed entities... so "blank" was saved without changes but after opening the draft changes appear. |
Savepoints in update forms+ updating entities result in a blank list with only the entity being updated Steps to reproduce the problem
Should I file a separate issue or it's connected? |
Deleting the entity while it’s being updated in a device with match exactly Steps to reproduce the problem
|
After doing some research into SQLite, I can add another problem to the list here. I'll post my full notes below, but the TLDR is that we can't write to the entities DB concurrently meaning that an offline create/update would block if it tried to run at the same time as we were updating entities from the server (because Full notes here:
|
We're going to go with blocking form updates during form entry (with back off). I'll update the issue description. |
@lognaturel @grzesiek2010 let me know if the updated issue description makes sense! If you agree, I think this is ready to go. |
I did a quick spike on this just to see how feasible it was. I ended up adding FormFillingActivity @Override
public void onCreate(Bundle savedInstanceState) {
Collect.getInstance().getComponent().inject(this);
if (savedInstanceState == null) {
sessionId = formSessionRepository.create();
changeLockProvider.create(projectsDataService.getCurrentProject().getUuid()).getFormsLock().lock();
} else {
sessionId = savedInstanceState.getString(KEY_SESSION_ID);
} FormEntryViewModel public void exit() {
formSessionRepository.clear(sessionId);
ReferenceManager.instance().reset();
AppDependencyComponent component = Collect.getInstance().getComponent();
component.changeLockProvider().create(component.currentProjectProvider().getCurrentProject().getUuid()).getFormsLock().unlock();
} These examples are obviously not particularly "clean", but it did appear to work and didn't cause any tests to fail - as far as I could tell the "try again when locked" part of the behaviour is already implemented for the background tasks (but this is worth double-checking of course). I think taking a direction like this would work, but it would definitely be better to have the I didn't dive into blocking loading if an update is happening. Form loading is currently very tangled up in I also gave some thought to testing: it feels like checking that an update can't start during form entry will be easy enough from an integration level (we already test background tasks from there), but I think the other way around is pretty tricky (and might involve some refactoring to make unit testing around loading more feasible). |
Blocked by #6012It's currently possible to load entities in a follow-up form while they're being updated (by match exactly or previously download only form updates) which can result in various problems like partial entity lists.
To fix this, automatic form updates (exactly match server or previously downloaded only) should not be able to run during form entry. In the case this does happen, the form update should try to run again with exponential back off rather than wait for the next scheduled run (like we do with auto send failures).
If form entry is started during an update, the form should not load until form entry has finished. Ideally we'd flag this in the progress dialog shown while loading a form, but it might be easier to do this as a follow-up down the road.
Notes
It's likely that this can be implemented using the existing forms
ChangeLock
. The form updates already respect this so we just have to make sure we correctly lock/unlock this during form entry (as well as wait for the lock when loading a form).The text was updated successfully, but these errors were encountered: