Another question is about a connection to Badger.
I need to open the database and then add a subscription, but when trying to open it I get the error: Cannot acquire directory lock on "/dgraph/p". Another process is using this Badger database.: resource temporarily unavailable
As far as I understand it’s because Dgraph has already opened the base.
What is the right way to connect to Badger in this case?
Sorry, I misunderstood the problem. Badger acquires an exclusive lock over the directory to prevent multiple processes from using it.
I don’t think there is a way to use the subscription of badger to subscribe over changes made by dgraph as both will be separate processes. This will essentially require some kind of publisher-subscriber model which the team/community wants to have but is not on the immediate roadmap.
Tagging @ibrahim, if he knows of some low-level hacks.
@Naman, just wanted to give a +1 and my 2 cents on publish-subscribe.
IMO, the custom mutation feature should be extended in some way, so that clients can register their callbacks. This allows a pub-sub mechanism, and hides badger implementation detail. This can then be used by a wider community for a large number of use cases (such as distribution of master data, or notification bridges between microservice domains).
There is a non-recommended way of doing this. You can open the p directory using a second badger instance and set the following options BypassLockGuard and ReadOnly to true.
Please note that this option isn’t thoroughly tested and could issues with dgraph when two badger instances are using the same directory (that’s why we have the lock).