Properly disable MultiCFIterator in WritePrepared/UnPreparedTxnDBs (#12883)

Summary:
MultiCfIterators (`CoalescingIterator` and `AttributeGroupIterator`) are not yet compatible with write-prepared/write-unprepared transactions, yet (write-committed is fine). This fix includes the following.

- Properly return `ErrorIterator` if the user attempts to use the `CoalescingIterator` or `AttributeGroupIterator` in WritePreparedTxnDB (and WriteUnpreparedTxnDB)
- Set `use_multi_cf_iterator = 0` if `use_txn=1` and `txn_write_policy != 0 (WRITE_COMMITTED)` in stress test.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/12883

Test Plan:
Works
```
./db_stress ... --use_txn=1 --txn_write_policy=0 --use_multi_cf_iterator=1
```

Fails
```
./db_stress ... --use_txn=1 --txn_write_policy=1 --use_multi_cf_iterator=1
```

Reviewed By: cbi42

Differential Revision: D60190784

Pulled By: jaykorean

fbshipit-source-id: 3bc1093e81a4ef5753ba9b32c5aea997c21bfd33
This commit is contained in:
Jay Huh 2024-07-24 16:50:12 -07:00 committed by Facebook GitHub Bot
parent f456a7213f
commit 086849aa4f
2 changed files with 19 additions and 0 deletions

View file

@ -844,6 +844,8 @@ def finalize_and_sanitize(src_params):
# Wide-column pessimistic transaction APIs are initially supported for
# WriteCommitted only
dest_params["use_put_entity_one_in"] = 0
# MultiCfIterator is currently only compatible with write committed policy
dest_params["use_multi_cf_iterator"] = 0
# TODO(hx235): enable test_multi_ops_txns with fault injection after stabilizing the CI
if dest_params.get("test_multi_ops_txns") == 1:
dest_params["write_fault_one_in"] = 0

View file

@ -13,6 +13,7 @@
#include <unordered_map>
#include <vector>
#include "db/attribute_group_iterator_impl.h"
#include "db/db_iter.h"
#include "db/pre_release_callback.h"
#include "db/read_callback.h"
@ -101,6 +102,22 @@ class WritePreparedTxnDB : public PessimisticTransactionDB {
const std::vector<ColumnFamilyHandle*>& column_families,
std::vector<Iterator*>* iterators) override;
using DB::NewCoalescingIterator;
std::unique_ptr<Iterator> NewCoalescingIterator(
const ReadOptions& /*options*/,
const std::vector<ColumnFamilyHandle*>& /*column_families*/) override {
return std::unique_ptr<Iterator>(
NewErrorIterator(Status::NotSupported("Not supported yet")));
}
using DB::NewAttributeGroupIterator;
std::unique_ptr<AttributeGroupIterator> NewAttributeGroupIterator(
const ReadOptions& /*options*/,
const std::vector<ColumnFamilyHandle*>& /*column_families*/) override {
return NewAttributeGroupErrorIterator(
Status::NotSupported("Not supported yet"));
}
// Check whether the transaction that wrote the value with sequence number seq
// is visible to the snapshot with sequence number snapshot_seq.
// Returns true if commit_seq <= snapshot_seq