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.

realm.commitTransation takes extremely long up to ANR after migrating from 3.0.0

See original GitHub issue

With updating realm plugin from 3.0.0 to current my writing to database performance degrades very badly from couple of seconds with hundreds of items to ANRs when given table has 4000 rows.

From my examining I found that any subsequent commiting a editing transation to realm hangs up, but queries are fine, also inserts are fine. Also, if I insert to different table, it works, so only that one with larger amount of data has this problem. However it doesnt seem to be a deadlocking type of situation, as where I wait for a minute and dont close the app on anr dialog, the operation actually completes eventually.

Use case of my app is that upon pull to refresh it add new rows to given Ads table. I am adding them via 1 transation, so this hopefully is not the issue

public ArrayList<Long> addAdsToFilter(Filter filter, LinkedHashMap<String, Ad> remoteAds) {
        ArrayList<Long> newAdIds = new ArrayList<>();
        mRealm.executeTransaction(realm -> {
            AtomicLong idCounter = RealmUtils.getIdCounter(realm, Ad.class);
            for (String key : remoteAds.keySet()) {
                Ad ad = remoteAds.get(key);
                long id = idCounter.incrementAndGet();
                ad.setId(id);
                ad.setFilter(filter);
                filter.addAd(ad);
                newAdIds.add(id);
            }
        });
        return newAdIds;
    }

However the weird thing about simulating this bug is that it only shows its self after 2nd pull to refresh inserts. Before that even with 4000 items transations commit fine.

So the simulation is: 1 pull to refresh; editing any object - OK, 2. pull to refresh, now edit any object from that table and operation hangs up . (… however only updates seem to be problem, inserts work, so if I dont edit any object after 2nd refresh, I can insert data with 3rd refresh no problem)

Thank you for your help, let me know if you need me to provide you with more info

Realm version(s): 3.3.2 Realm sync feature enabled: no Android Studio version: 2.3.2 Which Android version and device: any

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ursusursuscommented, Jun 26, 2017

Sorry I am currently busy, I will get back to you asap

0reactions
cmelchiorcommented, Jul 7, 2017

If you still have this issue and can reproduce in a sample project, feel free to re-open @ursusursus.

Closing for now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Realm: Create reactive mobile apps in a fraction ... - MongoDB
Note: Realm does not currently support Java outside of Android. We no longer support Eclipse as an IDE; please migrate to Android Studio....
Read more >
ArrayIndexOutOfBoundException in Realm - Stack Overflow
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on ......
Read more >
How to use Realm for Android like a champ, and how to tell if ...
I've been using Realm for a long time (since v0.81.1), and I should note that I'm not affiliated with Realm. But since then,...
Read more >
Create reactive mobile apps in a fraction of the time - Realm
Once these two changes are made, simply refresh your gradle dependencies. If you are upgrading from a version prior to v0.88 you may...
Read more >
Fix list for IBM WebSphere Application Server traditional V9
PH42887, Kerberos error message after upgrading to 8.5.5.20 and 9.0.5.8 ... PH35329, If an extremely large number is input for LTPA timeout, it...
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