Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce access to atomic variables in a test #10909

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions utilities/transactions/write_prepared_transaction_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1684,22 +1684,23 @@ TEST_P(SeqAdvanceConcurrentTest, SeqAdvanceConcurrent) {
expected_commits = 0;
std::vector<port::Thread> threads;

linked = 0;
linked.store(0, std::memory_order_release);
std::atomic<bool> batch_formed(false);
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WriteThread::EnterAsBatchGroupLeader:End",
[&](void* /*arg*/) { batch_formed = true; });
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"WriteThread::JoinBatchGroup:Wait", [&](void* /*arg*/) {
linked++;
if (linked == 1) {
size_t orig_linked = linked.fetch_add(1, std::memory_order_acq_rel);
if (orig_linked == 0) {
// Wait until the others are linked too.
while (linked < first_group_size) {
while (linked.load(std::memory_order_acquire) < first_group_size) {
}
} else if (linked == 1 + first_group_size) {
} else if (orig_linked == first_group_size) {
// Make the 2nd batch of the rest of writes plus any followup
// commits from the first batch
while (linked < txn_cnt + commit_writes) {
while (linked.load(std::memory_order_acquire) <
txn_cnt + commit_writes) {
}
}
// Then we will have one or more batches consisting of follow-up
Expand Down Expand Up @@ -1731,14 +1732,15 @@ TEST_P(SeqAdvanceConcurrentTest, SeqAdvanceConcurrent) {
FAIL();
}
// wait to be linked
while (linked.load() <= bi) {
while (linked.load(std::memory_order_acquire) <= bi) {
}
// after a queue of size first_group_size
if (bi + 1 == first_group_size) {
while (!batch_formed) {
}
// to make it more deterministic, wait until the commits are linked
while (linked.load() <= bi + expected_commits) {
while (linked.load(std::memory_order_acquire) <=
bi + expected_commits) {
}
}
}
Expand Down