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

Stress/Crash Test for OptimisticTransactionDB #11513

Closed

Conversation

jaykorean
Copy link
Contributor

@jaykorean jaykorean commented Jun 5, 2023

Context:
OptimisticTransactionDB has not been covered by db_stress (including crash test) like TransactionDB.

Summary:

  1. Adding the following gflag options to to test OptimisticTransactionDB
  • use_optimistic_txn: When true, open OptimisticTransactionDB to test
  • occ_validation_policy: OccValidationPolicy::kValidateParallel = 1 by default.
  • share_occ_lock_buckets: Use shared occ locks
  • occ_lock_bucket_count: 500 by default. Number of buckets to use for shared occ lock.
  1. Opening OptimisticTransactionDB and NewTxn/Commit added per use_optimistic_txn flag in db_stress_test_base.cc
  2. OptimisticTransactionDB blackbox/whitebox test added in crash_test.mk

Please note that the existing flag use_txn is being used here. When use_txn == true and use_optimistic_txn == false, we use TransactionDB (a.k.a. pessimistic transaction db). When both use_txn and use_optimistic_txn are true, we use OptimisticTransactionDB. If use_txn == false but use_optimistic_txn == true throw error with message "You cannot set use_optimistic_txn true while use_txn is false. Please set use_txn true if you want to use OptimisticTransactionDB".

Test Plan:

Crash Test
Serial Validation

export CRASH_TEST_EXT_ARGS="--use_optimistic_txn=1 --use_txn=1 --use_put_entity_one_in=0 --occ_validation_policy=0"
make crash_test -j

Parallel Validation (no share bucket)

export CRASH_TEST_EXT_ARGS="--use_optimistic_txn=1 --use_txn=1 --use_put_entity_one_in=0 --occ_validation_policy=1 --share_occ_lock_buckets=0" 
make crash_test -j

Parallel Validation (share bucket)

export CRASH_TEST_EXT_ARGS="--use_optimistic_txn=1 --use_txn=1 --use_put_entity_one_in=0 --occ_validation_policy=1 --share_occ_lock_buckets=1 --occ_lock_bucket_count=500" 
make crash_test -j

Stress Test

./db_stress -use_optimistic_txn -threads=32

@jaykorean jaykorean force-pushed the stress_test_for_optimistic_txn_db branch from 363d7cb to 3c61e8f Compare June 5, 2023 19:37
@pdillinger pdillinger self-requested a review June 7, 2023 15:48
Copy link
Contributor

@pdillinger pdillinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start. Doesn't look like this is connected up to the transaction testing code that is guarded by FLAGS_use_txn, though that could be put in a next PR. We will need to essentially audit all those places and decide which apply to OTDB. You can decide how to resolve mixing --use_txn and --use_optimistic_txn options, or not mixing, and whether it makes sense to keep checking FLAGS_use_txn or to introduce another variable for transactions in general.

tools/db_crashtest.py Show resolved Hide resolved
@@ -37,6 +39,11 @@ crash_test_with_txn: $(DB_STRESS_CMD)
$(CRASHTEST_MAKE) whitebox_crash_test_with_txn
$(CRASHTEST_MAKE) blackbox_crash_test_with_txn

crash_test_with_optimistic_txn: $(DB_STRESS_CMD)
# Do not parallelize
Copy link
Contributor Author

@jaykorean jaykorean Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering why we shouldn't parallelize. (copied from other tests as I assume the requirement is the same for OTDB, but I'd love to learn)

@jaykorean jaykorean force-pushed the stress_test_for_optimistic_txn_db branch from 0017999 to 0099e44 Compare June 7, 2023 22:17
@jaykorean jaykorean marked this pull request as ready for review June 8, 2023 03:23
@jaykorean jaykorean requested a review from pdillinger June 8, 2023 03:24
@facebook-github-bot
Copy link
Contributor

@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jaykorean has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@pdillinger pdillinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (Be sure to re-import)

@facebook-github-bot
Copy link
Contributor

@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jaykorean merged this pull request in 17d5200.

@jaykorean jaykorean deleted the stress_test_for_optimistic_txn_db branch June 17, 2023 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants