LiteFS - Check ifPrimary on node and replication status

In LiteFS docs and examples it shows the following:

  • Checking if current node is primary is done by checking if .primary file exist on node and doing an IO command with cat /path/to/mnt/.primary to get the primary host name.
    Is there a way to avoid IO calls to check ifPrimary for each edit call?

    Although it is possible to get if node is primary on node start I imagine that when working with
    dynamic lease (consul) it will change and I assume LiteFS have a listener on those changes.
    So the above question is crucial.

  • From what I understand, checking replication status is done by checking the position file in each node.
    My question here is similar - If I want to monitor the status of DB edits and replication, how can I do it?
    Can it be done without using IO (cat /path/to/mnt/db-pos) with every collection we want to do to monitor this on the different nodes?

Thank you

Not currently. We’ll add an endpoint for streaming events for the node so the application can listen from there. That’ll include primary/replica state changes as well as replication position changes. That will likely come out on the next release after v0.3.0.

What’s your concern regarding IO calls? Performance?

Thanks for your response.
Yes, my main concern is performance.

Can you please elaborate on the expected timeline for this release?

I’m hoping to release v0.3.0 next week. It mostly depends on finishing up docs and final testing.

1 Like