Skip to content
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

Better error message when calling refresh() during a transaction #1712

Closed
markini opened this issue Nov 1, 2015 · 2 comments
Closed

Better error message when calling refresh() during a transaction #1712

markini opened this issue Nov 1, 2015 · 2 comments

Comments

@markini
Copy link

markini commented Nov 1, 2015

Hello, I switched from 0.82.2 to 0.84.1 and it seems, that it is no longer possible to refresh a realm while doing a transaction:

Realm realm = Realm.getDefaultInstance();

realm.beginTransaction();
realm.refresh();
realm.commitTransaction();

Didn't see this in the changelog. Was this change intentionally?
This is the error:

11-01 22:00:15.645 31067-31067/my.my.app E/AndroidRuntime: FATAL EXCEPTION: main
io.realm.exceptions.RealmError: Unrecoverable error. Wrong transactional state (no active transaction, wrong type of transaction, or transaction already in progress) in io_realm_internal_SharedGroup.cpp line 157
    at io.realm.internal.SharedGroup.nativeAdvanceRead(Native Method)
    at io.realm.internal.SharedGroup.advanceRead(SharedGroup.java:86)
    at io.realm.internal.ImplicitTransaction.advanceRead(ImplicitTransaction.java:33)
    at io.realm.internal.SharedGroupManager.advanceRead(SharedGroupManager.java:76)
    at io.realm.BaseRealm.refresh(BaseRealm.java:280)
    at io.realm.Realm.refresh(Realm.java:113)
    at my.my.app.MyApplication.onCreate_aroundBody0(MyApplication.java:56)
    at my.my.app.MyApplication$AjcClosure1.run(MyApplication.java:1)
    at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
    at hugo.weaving.internal.Hugo.logAndExecute(Hugo.java:39)
    at my.my.app.MyApplication.onCreate(MyApplication.java:28)
    at my.my.app.DebugApplication.onCreate_aroundBody0(DebugApplication.java:13)
    at my.my.app.DebugApplication$AjcClosure1.run(DebugApplication.java:1)
    at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
    at hugo.weaving.internal.Hugo.logAndExecute(Hugo.java:39)
    at my.my.app.DebugApplication.onCreate(DebugApplication.java:13)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4684)
    at android.app.ActivityThread.access$1400(ActivityThread.java:159)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:5419)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
    at dalvik.system.NativeStart.main(Native Method)
@cmelchior
Copy link
Contributor

Hi @markini
Yes, that is intentional and is due to some error checking we activated in the underlying storage engine.
Calling refresh() during a transaction doesn't make any sense semantically as write transactions are blocking. This means that calling refresh during the transaction won't do anything as you are automatically at the latest version. The error message could be a lot clearer though and we should fix that.

@cmelchior cmelchior changed the title Can't realm.refresh() while doing a transaction Better error message when calling refresh() during a transaction Nov 1, 2015
@cmelchior
Copy link
Contributor

Fixed by #1768

@cmelchior cmelchior removed the P2 label Nov 16, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants