WriteUnPrepared: fix ubsan complaint (#5148)

Summary:
Ubsna complains that in initialization of WriteUnpreparedTxnReadCallback the method of the child class is used before the parent class is constructed. The patch fixes that by making the aforementioned method static.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5148

Differential Revision: D14760098

Pulled By: maysamyabandeh

fbshipit-source-id: cf19b7c1fdb5de0a54e62c1deebe09a0fa048ded
main
Maysam Yabandeh 6 years ago committed by Facebook Github Bot
parent ebb9b2ed16
commit 7441a0ecba
  1. 7
      utilities/transactions/write_unprepared_txn.h

@ -42,14 +42,15 @@ class WriteUnpreparedTxnReadCallback : public ReadCallback {
// TODO(myabandeh): override Refresh when Iterator::Refresh is supported // TODO(myabandeh): override Refresh when Iterator::Refresh is supported
private: private:
SequenceNumber CalcMaxVisibleSeq(WriteUnpreparedTxn* txn, static SequenceNumber CalcMaxVisibleSeq(WriteUnpreparedTxn* txn,
SequenceNumber snapshot_seq) { SequenceNumber snapshot_seq) {
SequenceNumber max_unprepared = CalcMaxUnpreparedSequenceNumber(txn); SequenceNumber max_unprepared = CalcMaxUnpreparedSequenceNumber(txn);
assert(snapshot_seq < max_unprepared || max_unprepared == 0 || assert(snapshot_seq < max_unprepared || max_unprepared == 0 ||
snapshot_seq == kMaxSequenceNumber); snapshot_seq == kMaxSequenceNumber);
return std::max(max_unprepared, snapshot_seq); return std::max(max_unprepared, snapshot_seq);
} }
SequenceNumber CalcMaxUnpreparedSequenceNumber(WriteUnpreparedTxn* txn); static SequenceNumber CalcMaxUnpreparedSequenceNumber(
WriteUnpreparedTxn* txn);
WritePreparedTxnDB* db_; WritePreparedTxnDB* db_;
WriteUnpreparedTxn* txn_; WriteUnpreparedTxn* txn_;
SequenceNumber wup_snapshot_; SequenceNumber wup_snapshot_;

Loading…
Cancel
Save