rocksdb/utilities/transactions
Yi Wu 5d4fddfa52 WritePrepared: Fix visible key compacted out by compaction (#4883)
Summary:
With WritePrepared transaction, flush/compaction can contain uncommitted keys, and those keys can get committed during compaction. If a snapshot is taken before the key is committed, it should not see the key. On the other hand, compaction grab the list of snapshots at its beginning, and only consider those snapshots to dedup keys. Consider the case:
```
seq = 1: put "foo" = "bar"
seq = 2: transaction T: delete "foo", prepare
seq = 3: compaction start
seq = 4: take snapshot S
seq = 5: transaction T: commit.
...
seq = N: compaction iterator reached key "foo".
```
When compaction start, the list of snapshot is empty. Compaction doesn't take snapshot S into account. When it reached "foo", transaction T is committed. Compaction may think the value "foo=bar" is not visible by any snapshot (which is wrong), and compact the value out.

The fix is to explicitly take a snapshot before compaction grabbing the list of snapshots. Compaction will then has to keep keys visible to this snapshot.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4883

Differential Revision: D13668775

Pulled By: maysamyabandeh

fbshipit-source-id: 1cab9615f94b7d3e8522cc3d44c3a14c7d4720e4
2019-01-15 21:34:38 -08:00
..
optimistic_transaction.cc
optimistic_transaction.h
optimistic_transaction_db_impl.cc
optimistic_transaction_db_impl.h
optimistic_transaction_test.cc
pessimistic_transaction.cc WritePrepared: snapshot should be larger than max_evicted_seq_ (#4886) 2019-01-15 18:11:52 -08:00
pessimistic_transaction.h WritePrepared: snapshot should be larger than max_evicted_seq_ (#4886) 2019-01-15 18:11:52 -08:00
pessimistic_transaction_db.cc
pessimistic_transaction_db.h
snapshot_checker.cc
transaction_base.cc
transaction_base.h
transaction_db_mutex_impl.cc
transaction_db_mutex_impl.h
transaction_lock_mgr.cc
transaction_lock_mgr.h
transaction_test.cc
transaction_test.h
transaction_util.cc
transaction_util.h
write_prepared_transaction_test.cc WritePrepared: Fix visible key compacted out by compaction (#4883) 2019-01-15 21:34:38 -08:00
write_prepared_txn.cc WritePrepared: snapshot should be larger than max_evicted_seq_ (#4886) 2019-01-15 18:11:52 -08:00
write_prepared_txn.h
write_prepared_txn_db.cc WritePrepared: snapshot should be larger than max_evicted_seq_ (#4886) 2019-01-15 18:11:52 -08:00
write_prepared_txn_db.h WritePrepared: snapshot should be larger than max_evicted_seq_ (#4886) 2019-01-15 18:11:52 -08:00
write_unprepared_transaction_test.cc
write_unprepared_txn.cc WritePrepared: Report released snapshots in IsInSnapshot (#4856) 2019-01-08 14:47:29 -08:00
write_unprepared_txn.h
write_unprepared_txn_db.cc WritePrepared: Report released snapshots in IsInSnapshot (#4856) 2019-01-08 14:47:29 -08:00
write_unprepared_txn_db.h