Skip to content

Instantly share code, notes, and snippets.

@zsxwing
Created September 22, 2021 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsxwing/d520f3cbe838e40582c20b7f19e661e5 to your computer and use it in GitHub Desktop.
Save zsxwing/d520f3cbe838e40582c20b7f19e661e5 to your computer and use it in GitHub Desktop.
val version = getCurrentVersionFromConnector
val appId = getCurrentAppIdFromConnector
val txn = startTxn()
val versionInTxn = txn.txnVersion(appId)
if (version <= versionInTxn) {
// Skip the write that's done
return
}
// write files and commit
txn.commit(SetTxn(appId, version) :: ... :: Nil) // system crash
// save the version id to somewhere for recovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment