Skip to content

Multi process support #193

Open
Open

Description

@nickylin

we want to use the data in multi process, but i dont know whether this can use ?

Activity

  1. greenrobot commented on Sep 27, 2017

    @greenrobot
    Member

    You should be with one exception: It is not supportted at the moment. To make it work we have to:

    • reactive queries do not work across processes.
    • ID assignment currently works NOT accross processes - multiple processes would overwrite each other when inserting
    • we have to guard initialization so only one process boots up the DB at a time
  2. changed the title [-]Is this support to use in multi process? [/-] [+]Multi process support[/+] on Sep 27, 2017
  3. added
    enhancement
    on Oct 1, 2017
  4. jpmcosta commented on Nov 14, 2017

    @jpmcosta

    If I understood correctly, it's still not possible to listen for changes that originated in different processes.
    Any idea on when will this be supported?

  5. greenrobot commented on Nov 15, 2017

    @greenrobot
    Member

    Multi process might be bumpy at the moment. Can you tell us about your use case?

  6. jpmcosta commented on Nov 15, 2017

    @jpmcosta

    @greenrobot not sure if it's relevant enough to pollute this issue. I have a service in a different process that's responsible to build all the data.

  7. greenrobot commented on Nov 15, 2017

    @greenrobot
    Member

    It's always relevant to see how features are (intended to be ) used; sometimes it's surprising.

    Got it. And why did you decide to give the Service its own process?

  8. jpmcosta commented on Nov 15, 2017

    @jpmcosta

    It's mainly for better memory management. I might be over-engineering.

  9. greenrobot commented on Dec 7, 2017

    @greenrobot
    Member

    Sorry, I had to revise my initial comment. Multiple processes are not supported at the moment!

  10. nickylin commented on Dec 8, 2017

    @nickylin
    Author

    ok got it , thx bro

  11. greenrobot commented on Dec 9, 2019

    @greenrobot
    Member

    Btw, additional read-only processes might even work if they do not rely on reactive queries / data change listeners.

  12. added this to the 2.7.0 milestone on Sep 8, 2020
  13. greenrobot-team commented on Sep 8, 2020

    @greenrobot-team
    Member

    2.7.0 introduced read-only stores that enable multi-process support.

    There is an example: https://github.com/objectbox/objectbox-examples/tree/main/android-app-multiprocess

    Inter-process data observers are in preparation: #893

  14. tomwassink commented on Oct 16, 2020

    @tomwassink

    Thanks for working on this subject! I have multiple read and write operations in two separate processes. Currently it it is working quite well for most boxes except one. In this case I write in both processes. For the others it is either one of them writing.

    For the one with the issues I have the issue with the error: "Error when updating with existing Id's..." (As a workaround I delete all items and add them again after it....). But also some unexpected loss of items when writing quit fast "couple of seconds" after each other.

    Is it planned to support writing from multiple processes in the future?

  15. greenrobot commented on Oct 17, 2020

    @greenrobot
    Member

    Is it planned to support writing from multiple processes in the future?

    According to our current plans, not in the near future. We advise to use one writer process and use IPC from other processes for writes via the writer process.

  16. u007 commented on Nov 24, 2020

    @u007

    in my project, I moved the objectbox.init into service to avoid multiple initialization. and do a code to wait for it to be available:

    override fun onPostCreate(savedInstanceState: Bundle?) {
            super.onPostCreate(savedInstanceState)
    
            GlobalScope.launch {
                while(true) {
                    try {
                        if(ObjectBox.boxStore == null) {
                            Log.d(AdService.TAG, "Waiting for objectbox.")
                            return@launch
                        }
    
                        return@launch this@FullscreenActivity.runOnUiThread {
                            renderApp(savedInstanceState)
                        }
                    } catch(e: java.lang.Exception) {
                        // skipped starting issue
                        Log.d(AdService.TAG, "Waiting for objectbox", e)
                    }
    
                    delay(1000)
                }
            }
        }
    
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions