Skip to content

cleanup a bunch of stuff related to compare and swap requests

Georgy Moshkin requested to merge gmoshkin/compare-and-swap-code-cleanup into master

Summary

  • fix: used to sometimes report incorrect raft term immediately after restarting

  • fix: use picodata's system connection pool for CAS requests

  • fix: unify which term is used for cas predicates

CAS predicates should always contain the current raft term, because this is what's explicitly checked in proc_cas.

Note that this will sometimes result in a EntryTermMismatch error because the latest applied entry may have a different term in case the election has started but not finished yet.

We could add this check to all the client cas precondition checks, but it's not a big deal, because we handle the situation correctly anyways.

  • refactor: move wait_index into compare_and_swap

  • refactor: compare_and_swap now accepts a deadline instead of a timeout

  • refactor: massage compare_and_swap a bit

  • fix: unify all places where we call compare_and_swap and wait for the result

  • fix: check if DdlPrepare was rolled back before waiting for DdlCommit

Rolled back as in raft log roll back, which can happen when a leader changes to one who doesn't have the entry we persisted. Not to be confused with DdlAbort.

  • fix: cas requests are always reconstructed before retrying

  • fix: TermMismatch was always retriable, when did it stop?

  • doc: add comments to retriable error codes explaing why they are retriable


  • Cherry-pick to: none
  • Docs follow-up: not necessary

Merge request reports