question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bidirectional links Caused slowness when parsing collection changeset

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jpmcostacommented, May 4, 2017

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:

getRealm().executeTransaction(new Realm.Transaction() {

    @Override
    public void execute(Realm realm) {
        Filter filter = realm.where(Filter.class).equalTo("id", 0).findFirst();
        filter.isEnabled = !filter.isEnabled;
    }
});

I’ve tried to remove parentFeed from Item, to see the impact it might have, and I found that if Item has a parentFeed 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, 10 Feeds, 10 Items, no repeated links, and 3 Filters pointing to App#0, these were some of my results:

[test 0] time: 2235
[test 1] time: 590
[test 2] time: 144
[test 3] time: 406
[test 4] time: 507
[test 5] time: 373
[test 6] time: 1030
[test 7] time: 270
[test 8] time: 1519
[test 9] time: 1911
[test 1] time: 656
[test 2] time: 16650
[test 3] time: 19002
[test 4] time: 27234
[test 5] time: 13973
[test 6] time: 5564
[test 7] time: 12968
[test 8] time: 69333
[test 9] time: 3139
[test 10] time: 8201
1reaction
beeendercommented, May 4, 2017

For the specific case here, the Filter actually only has a single direction link to the App. And change Filter.isEnabled should effect other Filter 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Short History of Bi-Directional Links - Maggie Appleton
We set up all these single-direction paths, trying to signal relevance and context, only to have the other side completely ignore our efforts....
Read more >
Drools Expert User Guide - Red Hat on GitHub - JBoss.org
A Knowledge Base is what we call our collection of compiled definitions, such as rules and ... To facilitate this, Drools supports the...
Read more >
Hibernate / "absolutely necessary with bi-directional links"?
In summary, from my reading of the docs it is not absolutely necessary, but failing to add the inverse-side entity to the collection...
Read more >
Drupal 7 module for parse some sites to entities - gists · GitHub
Drupal 7 module for parse some sites to entities. GitHub Gist: instantly share code, notes, and snippets.
Read more >
US7069497B1 - System and method for applying a partial page ...
A system and method for applying a partial page change to a browser page formatted according to Hypertext Markup Language (HTML).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found