earth-mover / icechunk

Open-source, cloud-native transactional tensor storage engine
https://icechunk.io
Apache License 2.0
291 stars 17 forks source link

Conflict detection and rebase #374

Open paraseba opened 2 weeks ago

paraseba commented 2 weeks ago

Design document

Goal

Goal here is to describe and finish designing the mechanism to "rebase" changes.

When user A tries to commit a change, currently the commit will fail if user B committed since A's session started. This is the best and safest default, but it's not necessarily what A wants every time. For example maybe A wrote to array /array_a and B wrote to /array_b and those changes are unrelated. In a case like that, A may decide to still do the commit, accepting the risks if they know exactly what B changes were.

A rebase is then, the process of "merging" a change, potentially modifying it, on top of other pre-existing changes.

We want to provide:

Transaction logs

As part of this change we will introduce the concept of TransactionLog. These are files we will store on-disk, in their own prefix, and with the same id as the corresponding snapshot. The transaction log contains a serialization, somewhat expanded, of the ChangeSet.

They provide at least two utilities:

Transaction logs will be generated from the ChangeSet (and probably a bit of extra information, like the list of existing nodes), and they will be written during the commit process.

Transaction logs can be made optional. For ultimate performance users may choose not to use them, but in that case, they'll be giving up on rebase and diff functionality.

Conflict resolution

In the most detailed case, conflict resolution could be done interactively. Users may want to investigate their own change, together with the diffs of the conflicting changes, and decide with full detail how to modify their change for the rebase. This sounds like a very advanced usage, and we don't need to support it initially. We just need to make sure it is possible in the future.

In the simpler case, the user will run rebase after a commit failed with conflict. They will call a rebase function, passing a ConflictSolver that includes the policy on how to deal with different types of conflicts.

Some conflict resolution examples

Exhaustive list of conflicts and resolutions

This is WIP