Lines Matching refs:thread
424 Status StressTest::SetOptions(ThreadState* thread) { in SetOptions() argument
428 options_index_[thread->rand.Next() % options_index_.size()]; in SetOptions()
429 int value_idx = thread->rand.Next() % options_table_[name].size(); in SetOptions()
446 int rand_cf_idx = thread->rand.Next() % FLAGS_column_families; in SetOptions()
488 void StressTest::OperateDb(ThreadState* thread) { in OperateDb() argument
491 auto shared = thread->shared; in OperateDb()
505 thread->stats.Start(); in OperateDb()
507 if (thread->shared->HasVerificationFailedYet() || in OperateDb()
508 thread->shared->ShouldStopTest()) { in OperateDb()
512 thread->stats.FinishedSingleOp(); in OperateDb()
513 MutexLock l(thread->shared->GetMutex()); in OperateDb()
514 while (!thread->snapshot_queue.empty()) { in OperateDb()
515 db_->ReleaseSnapshot(thread->snapshot_queue.front().second.snapshot); in OperateDb()
516 delete thread->snapshot_queue.front().second.key_vec; in OperateDb()
517 thread->snapshot_queue.pop(); in OperateDb()
519 thread->shared->IncVotedReopen(); in OperateDb()
520 if (thread->shared->AllVotedReopen()) { in OperateDb()
521 thread->shared->GetStressTest()->Reopen(thread); in OperateDb()
522 thread->shared->GetCondVar()->SignalAll(); in OperateDb()
524 thread->shared->GetCondVar()->Wait(); in OperateDb()
531 if (thread->shared->HasVerificationFailedYet()) { in OperateDb()
536 if (thread->rand.OneInOpt(FLAGS_set_options_one_in)) { in OperateDb()
537 SetOptions(thread); in OperateDb()
540 if (thread->rand.OneInOpt(FLAGS_set_in_place_one_in)) { in OperateDb()
544 if (thread->tid == 0 && FLAGS_verify_db_one_in > 0 && in OperateDb()
545 thread->rand.OneIn(FLAGS_verify_db_one_in)) { in OperateDb()
546 ContinuouslyVerifyDb(thread); in OperateDb()
547 if (thread->shared->ShouldStopTest()) { in OperateDb()
552 MaybeClearOneColumnFamily(thread); in OperateDb()
554 if (thread->rand.OneInOpt(FLAGS_sync_wal_one_in)) { in OperateDb()
561 int rand_column_family = thread->rand.Next() % FLAGS_column_families; in OperateDb()
564 if (thread->rand.OneInOpt(FLAGS_compact_files_one_in)) { in OperateDb()
565 TestCompactFiles(thread, column_family); in OperateDb()
568 int64_t rand_key = GenerateOneKey(thread, i); in OperateDb()
577 if (thread->rand.OneInOpt(FLAGS_compact_range_one_in)) { in OperateDb()
578 TestCompactRange(thread, rand_key, key, column_family); in OperateDb()
579 if (thread->shared->HasVerificationFailedYet()) { in OperateDb()
587 if (thread->rand.OneInOpt(FLAGS_flush_one_in)) { in OperateDb()
597 if (thread->rand.OneInOpt(FLAGS_get_live_files_one_in)) { in OperateDb()
605 if (thread->rand.OneInOpt(FLAGS_get_sorted_wal_files_one_in)) { in OperateDb()
614 if (thread->rand.OneInOpt(FLAGS_get_current_wal_file_one_in)) { in OperateDb()
623 if (thread->rand.OneInOpt(FLAGS_pause_background_one_in)) { in OperateDb()
624 Status status = TestPauseBackground(thread); in OperateDb()
632 if (thread->rand.OneInOpt(FLAGS_verify_checksum_one_in)) { in OperateDb()
642 if (thread->rand.OneInOpt(FLAGS_ingest_external_file_one_in)) { in OperateDb()
643 TestIngestExternalFile(thread, rand_column_families, rand_keys, lock); in OperateDb()
646 if (thread->rand.OneInOpt(FLAGS_backup_one_in)) { in OperateDb()
647 Status s = TestBackupRestore(thread, rand_column_families, rand_keys); in OperateDb()
654 if (thread->rand.OneInOpt(FLAGS_checkpoint_one_in)) { in OperateDb()
655 Status s = TestCheckpoint(thread, rand_column_families, rand_keys); in OperateDb()
662 if (thread->rand.OneInOpt(FLAGS_approximate_size_one_in)) { in OperateDb()
664 TestApproximateSize(thread, i, rand_column_families, rand_keys); in OperateDb()
670 if (thread->rand.OneInOpt(FLAGS_acquire_snapshot_one_in)) { in OperateDb()
671 TestAcquireSnapshot(thread, rand_column_family, keystr, i); in OperateDb()
675 Status s = MaybeReleaseSnapshots(thread, i); in OperateDb()
681 int prob_op = thread->rand.Uniform(100); in OperateDb()
693 std::min(static_cast<uint64_t>(thread->rand.Uniform(64)), in OperateDb()
697 rand_keys = GenerateNKeys(thread, multiget_batch_size, i); in OperateDb()
698 TestMultiGet(thread, read_opts, rand_column_families, rand_keys); in OperateDb()
701 TestGet(thread, read_opts, rand_column_families, rand_keys); in OperateDb()
710 TestPrefixScan(thread, read_opts, rand_column_families, rand_keys); in OperateDb()
714 TestPut(thread, write_opts, read_opts, rand_column_families, rand_keys, in OperateDb()
719 TestDelete(thread, write_opts, rand_column_families, rand_keys, lock); in OperateDb()
723 TestDeleteRange(thread, write_opts, rand_column_families, rand_keys, in OperateDb()
729 std::min(static_cast<uint64_t>(thread->rand.Uniform(4)), in OperateDb()
731 rand_keys = GenerateNKeys(thread, num_seeks, i); in OperateDb()
733 TestIterate(thread, read_opts, rand_column_families, rand_keys); in OperateDb()
735 thread->stats.FinishedSingleOp(); in OperateDb()
737 uint32_t tid = thread->tid; in OperateDb()
740 if (thread->rand.OneInOpt(FLAGS_secondary_catch_up_one_in)) { in OperateDb()
750 while (!thread->snapshot_queue.empty()) { in OperateDb()
751 db_->ReleaseSnapshot(thread->snapshot_queue.front().second.snapshot); in OperateDb()
752 delete thread->snapshot_queue.front().second.key_vec; in OperateDb()
753 thread->snapshot_queue.pop(); in OperateDb()
756 thread->stats.Stop(); in OperateDb()
762 std::vector<std::string> StressTest::GetWhiteBoxKeys(ThreadState* thread, in GetWhiteBoxKeys() argument
782 boundaries[thread->rand.Uniform(static_cast<int>(boundaries.size()))]; in GetWhiteBoxKeys()
783 if (thread->rand.OneIn(3)) { in GetWhiteBoxKeys()
794 } else if (thread->rand.OneIn(2)) { in GetWhiteBoxKeys()
814 Status StressTest::TestIterate(ThreadState* thread, in TestIterate() argument
824 if (thread->rand.OneIn(16)) { in TestIterate()
828 } else if (thread->rand.OneIn(4)) { in TestIterate()
838 if (thread->rand.OneIn(16)) { in TestIterate()
840 int64_t rand_upper_key = GenerateOneKey(thread, FLAGS_ops_per_thread); in TestIterate()
849 if (thread->rand.OneIn(16)) { in TestIterate()
851 int64_t rand_lower_key = GenerateOneKey(thread, FLAGS_ops_per_thread); in TestIterate()
863 if (thread->rand.OneIn(16)) { in TestIterate()
865 key_str = GetWhiteBoxKeys(thread, db_, cfh, rand_keys.size()); in TestIterate()
887 thread->rand.OneIn(2)) { in TestIterate()
891 int64_t rand_upper_key = GenerateOneKey(thread, FLAGS_ops_per_thread); in TestIterate()
895 thread->rand.OneIn(4)) { in TestIterate()
899 int64_t rand_lower_key = GenerateOneKey(thread, FLAGS_ops_per_thread); in TestIterate()
925 GetControlCfh(thread, rand_column_families[0]); in TestIterate()
932 if (support_seek_first_or_last && thread->rand.OneIn(100)) { in TestIterate()
937 } else if (support_seek_first_or_last && thread->rand.OneIn(100)) { in TestIterate()
942 } else if (thread->rand.OneIn(8)) { in TestIterate()
953 VerifyIterator(thread, cmp_cfh, readoptionscopy, iter.get(), cmp_iter.get(), in TestIterate()
959 if (no_reverse || thread->rand.OneIn(2)) { in TestIterate()
975 VerifyIterator(thread, cmp_cfh, readoptionscopy, iter.get(), in TestIterate()
980 thread->stats.AddIterations(1); in TestIterate()
983 thread->stats.AddErrors(1); in TestIterate()
1022 void StressTest::VerifyIterator(ThreadState* thread, in VerifyIterator() argument
1143 thread->stats.AddErrors(1); in VerifyIterator()
1145 thread->shared->SetVerificationFailure(); in VerifyIterator()
1182 ThreadState* thread, const std::vector<int>& rand_column_families, in TestBackupRestore() argument
1188 std::string backup_dir = FLAGS_db + "/.backup" + ToString(thread->tid); in TestBackupRestore()
1189 std::string restore_dir = FLAGS_db + "/.restore" + ToString(thread->tid); in TestBackupRestore()
1234 bool exists = thread->shared->Exists(rand_column_families[i], rand_keys[i]); in TestBackupRestore()
1267 ThreadState* thread, uint64_t iteration, in TestApproximateSize() argument
1275 if (thread->rand.OneIn(2)) { in TestApproximateSize()
1277 key2 = GenerateOneKey(thread, iteration); in TestApproximateSize()
1285 key2 = key1 + static_cast<int64_t>(thread->rand.Uniform(1000)); in TestApproximateSize()
1291 sao.include_memtabtles = thread->rand.OneIn(2); in TestApproximateSize()
1293 sao.include_files = thread->rand.OneIn(2); in TestApproximateSize()
1295 if (thread->rand.OneIn(2)) { in TestApproximateSize()
1296 if (thread->rand.OneIn(2)) { in TestApproximateSize()
1300 static_cast<double>(thread->rand.Uniform(3)); in TestApproximateSize()
1309 Status StressTest::TestCheckpoint(ThreadState* thread, in TestCheckpoint() argument
1317 FLAGS_db + "/.checkpoint" + ToString(thread->tid); in TestCheckpoint()
1357 thread->shared->Exists(rand_column_families[i], rand_keys[i]); in TestCheckpoint()
1389 void StressTest::TestCompactFiles(ThreadState* thread, in TestCompactFiles() argument
1398 thread->rand.Uniform(static_cast<int>(cf_meta_data.levels.size())); in TestCompactFiles()
1403 thread->rand.Uniform(static_cast<int>(files.size())); in TestCompactFiles()
1427 thread->stats.AddNumCompactFilesFailed(1); in TestCompactFiles()
1429 thread->stats.AddNumCompactFilesSucceed(1); in TestCompactFiles()
1445 Status StressTest::TestPauseBackground(ThreadState* thread) { in TestPauseBackground() argument
1456 std::min(thread->rand.Uniform(25), thread->rand.Uniform(25)); in TestPauseBackground()
1461 void StressTest::TestAcquireSnapshot(ThreadState* thread, in TestAcquireSnapshot() argument
1468 const bool ww_snapshot = thread->rand.OneIn(10); in TestAcquireSnapshot()
1484 if (FLAGS_compare_full_db_state_snapshot && (thread->tid == 0)) { in TestAcquireSnapshot()
1505 if (thread->rand.OneIn(10)) { in TestAcquireSnapshot()
1509 if (thread->rand.OneIn(10)) { in TestAcquireSnapshot()
1516 thread->snapshot_queue.emplace(release_at, snap_state); in TestAcquireSnapshot()
1519 Status StressTest::MaybeReleaseSnapshots(ThreadState* thread, uint64_t i) { in MaybeReleaseSnapshots() argument
1520 while (!thread->snapshot_queue.empty() && in MaybeReleaseSnapshots()
1521 i >= thread->snapshot_queue.front().first) { in MaybeReleaseSnapshots()
1522 auto snap_state = thread->snapshot_queue.front().second; in MaybeReleaseSnapshots()
1530 thread->snapshot_queue.pop(); in MaybeReleaseSnapshots()
1538 void StressTest::TestCompactRange(ThreadState* thread, int64_t rand_key, in TestCompactRange() argument
1551 cro.exclusive_manual_compaction = static_cast<bool>(thread->rand.Next() % 2); in TestCompactRange()
1552 cro.change_level = static_cast<bool>(thread->rand.Next() % 2); in TestCompactRange()
1559 bottom_level_styles[thread->rand.Next() % in TestCompactRange()
1561 cro.allow_write_stall = static_cast<bool>(thread->rand.Next() % 2); in TestCompactRange()
1562 cro.max_subcompactions = static_cast<uint32_t>(thread->rand.Next() % 4); in TestCompactRange()
1566 if (thread->rand.OneIn(2)) { in TestCompactRange()
1571 GetRangeHash(thread, pre_snapshot, column_family, start_key, end_key); in TestCompactRange()
1583 GetRangeHash(thread, pre_snapshot, column_family, start_key, end_key); in TestCompactRange()
1589 thread->stats.AddErrors(1); in TestCompactRange()
1591 thread->shared->SetVerificationFailure(); in TestCompactRange()
1597 uint32_t StressTest::GetRangeHash(ThreadState* thread, const Snapshot* snapshot, in GetRangeHash() argument
1618 thread->stats.AddErrors(1); in GetRangeHash()
1620 thread->shared->SetVerificationFailure(); in GetRangeHash()
2101 void StressTest::Reopen(ThreadState* thread) { in Reopen() argument
2108 if (write_prepared || thread->rand.OneIn(2)) { in Reopen()
2110 write_prepared || static_cast<bool>(thread->rand.OneIn(2)); in Reopen()
2117 (void) thread; in Reopen()
2126 if (thread->rand.OneIn(2)) { in Reopen()