vmware-archive / go-pmem-transaction

Golang library for using persistent memory
Other
29 stars 5 forks source link

Change how ptr to slice is logged #36

Closed mohit10verma closed 4 years ago

mohit10verma commented 5 years ago

When ptr to slice is passed to Log() method, user can change the sliceheader AND/OR the slice contents. So, for undo logging,

  1. we store the original sliceheader in the logs.
  2. In addition, for undo log, we store the original slice contents. This is useful during transaction abort. When a transaction commits, we should flush the new sliceheader and the new slice contents. And we don't need to flush the log entry storing the old slice contents.

For redo logging,

  1. We store the new sliceheader in the logs, and when the transaction commits, we should flush the new sliceheader and new slice contents.

Before this change, we used to have a field sliceElemSize in each log entry datastructure, indicating if it stored a sliceheader. This field was stored in pmem and was unnecessary for all other entries. This commit changes this implementation.

Because special things need to be done only when transaction commits, we store all this info in volatile memory now.

Testing done: Existing test cases test this feature. All of them pass.

vmwclabot commented 4 years ago

@mohit10verma, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.