realm-java: Bidirectional links Caused slowness when parsing collection changeset
Goal
I think I’ve found a bug that makes Realm freeze while trying to execute transactions to update data.
Results
My schema worked fine in Realm 2.3.0, but it doesn’t seem to work well in Realm 3.1.3.
Steps & Code to Reproduce
I’ve created a simple app to reproduce the bug: https://github.com/jpmcosta/RealmTestProject/tree/47b091215e2517ae337b88f6a5aeb597edf6542d:
- run the app;
- click on the FABs and on the items in the list;
- example: click 5 times on the left FAB, 5 times on right FAB, and then click once or twice on one of the items in the list.
- the app will eventually freeze and will have to be force closed.
Details of the app:
- left FAB will create a Filter, replicating my app’s use case (2 transactions):
- first, updates the data of a temporary Filter;
- then, copies the temporary Filter data to the actual Filter.
- right FAB will create an Item for every Feed (1 transaction);
- clicking on the items in the list (Filters) will update their
isEnabled
value (1 transaction).
Version of Realm and tooling
Realm version(s): 3.1.3
Android version: 5.1.1 (22)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 18 (13 by maintainers)
Commits related to this issue
- Test project for https://github.com/realm/realm-java/issues/4544 — committed to jpmcosta/RealmTestProject by jpmcosta 7 years ago
- Follow-up to https://github.com/realm/realm-java/issues/4544 — committed to jpmcosta/RealmTestProject by jpmcosta 7 years ago
I was trying to figure out if there was an infinite loop or not. I’ve modified the test app to run multiple tests on different graphs, but with the same number of objects. Here: https://github.com/jpmcosta/RealmTestProject/tree/cdd686001d5293a1ee3ab7b43ded542ea2b89b0d
The test is simply:
I’ve tried to remove
parentFeed
fromItem
, to see the impact it might have, and I found that ifItem
has aparentFeed
object, the testing times jump from a maximum of ~8000ms to a maximum of ~70000ms.I’ve run tests 1000+ times, with different
OBJECT_COUNT
, and indeed it doesn’t seem to exist an infinite loop, just really slow transaction times.With 10
Apps
, 10Feeds
, 10Items
, no repeated links, and 3Filters
pointing toApp#0
, these were some of my results:For the specific case here, the
Filter
actually only has a single direction link to theApp
. And changeFilter.isEnabled
should effect otherFilter
objects in the collection. I think that is something should be optimized in our parsing. But I don’t have too much ideas right now.