Skip to content

Simplify the prepare/commit phases to just try_commit #350

Closed as not planned
consensus-shipyard/fendermint
#26
@aakoshh

Description

A followup on #287

According to the RocksDB documentation, for OptimisticTransactionDB:

  • commit: will commit changes unless there is a conflict, in which case it will return Busy
  • prepare: writes to the WAL, so commit is simple, as the cost of making rollback more costly; it doesn't say that it would return Busy if there are conflicts

See:

If commit is the one which returns Busy then this is at odds with how STM expects it to work. Also, in STM we do the database prepare first, and the in-memory key checks second. We could do the other way around, though:

  1. locks the keys in the STM transaction first, detect conflicts there
  2. if a conflict is found, rollback the DB
  3. if there are no conflicts, then try_commit the database
  4. if try_commit returned true, write to the locked in-memory places
  5. if try_commit returned false, release the locks and try again

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions