terminusdb / terminusdb-store

a tokio-enabled data store for triple data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide a way to force update labels only when revision number matches

matko opened this issue · comments

We currently have a 'safe' update label, which ensures that the layer being put in place is a valid successor of the layer that was there previously. We also have a force update label which just replaces the current label regardless of what is there.

It turns out we need something in-between these two extremes. Sometimes we wish to update a label with something that is not a valid successor, but we do wish to ensure that the current label is in the state we expect it to be. This comes up when doing a squash - we need to make sure that our squashed layer contains all the data, and we didn't miss a commit. But if we squash based on the label state at time 0, and then at time 1 someone commits something extra, when we then force update the label at time 2, a commit is lost.

Luckily labels carry a revision number with them, so it should always be possible to prevent this. We simply need a version of update label that takes a revision number, and fails if the revision number does not match.