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

Improve stress test for transactions #9568

Closed
wants to merge 42 commits into from

Conversation

riversand963
Copy link
Contributor

@riversand963 riversand963 commented Feb 15, 2022

Test only, no change to functionality.
Extremely low risk of library regression.

Update test key generation by maintaining existing and non-existing keys.
Update db_crashtest.py to drive multiops_txn stress test for both write-committed and write-prepared.
Add a make target 'blackbox_crash_test_with_multiops_txn'.

Running the following commands caught the bug exposed in #9571.

$rm -rf /tmp/rocksdbtest/*
$./db_stress -progress_reports=0 -test_multi_ops_txns -use_txn -clear_column_family_one_in=0 \
    -column_families=1 -writepercent=0 -delpercent=0 -delrangepercent=0 -customopspercent=60 \
   -readpercent=20 -prefixpercent=0 -iterpercent=20 -reopen=0 -ops_per_thread=1000 -ub_a=10000 \
   -ub_c=100 -destroy_db_initially=0 -key_spaces_path=/dev/shm/key_spaces_desc -threads=32 -read_fault_one_in=0
$./db_stress -progress_reports=0 -test_multi_ops_txns -use_txn -clear_column_family_one_in=0
   -column_families=1 -writepercent=0 -delpercent=0 -delrangepercent=0 -customopspercent=60 -readpercent=20 \
   -prefixpercent=0 -iterpercent=20 -reopen=0 -ops_per_thread=1000 -ub_a=10000 -ub_c=100 -destroy_db_initially=0 \
   -key_spaces_path=/dev/shm/key_spaces_desc -threads=32 -read_fault_one_in=0

Running the following command caught a bug which will be fixed in #9648 .

$TEST_TMPDIR=/dev/shm make blackbox_crash_test_with_multiops_wc_txn

@riversand963 riversand963 added the WIP Work in progress label Feb 15, 2022
@riversand963 riversand963 force-pushed the config-txn-stress branch 2 times, most recently from f28cd93 to 333614c Compare February 16, 2022 00:23
@riversand963 riversand963 changed the title [WIP] Improve stress test for transactions Improve stress test for transactions Feb 16, 2022
@riversand963 riversand963 force-pushed the config-txn-stress branch 2 times, most recently from 936f45c to 4e73cb8 Compare February 17, 2022 18:14
@riversand963 riversand963 removed the WIP Work in progress label Feb 17, 2022
@riversand963 riversand963 force-pushed the config-txn-stress branch 2 times, most recently from c3d67cf to a60a865 Compare February 17, 2022 18:28
@riversand963 riversand963 marked this pull request as ready for review February 17, 2022 18:30
@facebook-github-bot
Copy link
Contributor

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

@riversand963
Copy link
Contributor Author

cc @lth

@facebook-github-bot
Copy link
Contributor

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

1 similar comment
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

Copy link
Contributor

@jay-zhuang jay-zhuang left a comment

Choose a reason for hiding this comment

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

LGTM

// location, and this file will be used by future runs until a new db is
// created.
//
// Create a fresh new dataabse (-destroy_db_initially=1 or there is no database
Copy link
Contributor

Choose a reason for hiding this comment

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

typo database

Comment on lines +21 to +28
DEFINE_int32(lb_a, 0, "(Inclusive) lower bound of A");
DEFINE_int32(ub_a, 1000, "(Exclusive) upper bound of A");
DEFINE_int32(lb_c, 0, "(Inclusive) lower bound of C");
DEFINE_int32(ub_c, 1000, "(Exclusive) upper bound of C");

DEFINE_string(key_spaces_path, "",
"Path to file describing the lower and upper bounds of A and C");
Copy link
Contributor

Choose a reason for hiding this comment

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

What are A key and C key? are they myrocks keys from https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format
I think we should explain the key format here and how to choose it, why the key range is int.
And we might want to name the stress test blackbox_crash_test_myrocks_multiops_wc

Copy link
Contributor Author

@riversand963 riversand963 Mar 16, 2022

Choose a reason for hiding this comment

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

The key format is described in multi_ops_txns_stress.h. I will put a comment here pointing to the header.
The stress test is not only for write-committed (wc)

Comment on lines +750 to +753
std::ostringstream oss;
oss << "pk should exist: " << Slice(pk).ToString(true);
fprintf(stderr, "%s\n", oss.str().c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should use std::cerr instead (maybe a future refactor PR)

Comment on lines +1250 to +1252
// Both [lb_a, ub_a) and [lb_c, ub_c) are partitioned. Each thread operates on
// one sub range, using KeyGenerators to generate keys.
Copy link
Contributor

Choose a reason for hiding this comment

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

If each thread is only operating on its own partition, does that mean we're not testing concurrent operations on the same key? Is it to mimic myrocks operation which only has single thread for a key-range?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even if multiple threads are operating on overlapping key ranges, at the db layer, there will never be concurrent accesses to the same key due to locking at Transaction layer. Having each thread operate on disjoint key ranges makes it easier for us to manage the existing and non-existing keys across different db restarts. This is necessary if we want the majority of read to actually find the keys instead of return not-found, in which case, we are not stressing the database as much.

// data specified via `-lb_a`, `-ub_a`, `-lb_c`, `-ub_c`, etc. Among these, we
// define the test key spaces as two key ranges: [lb_a, ub_a) and [lb_c, ub_c).
// The key spaces specification is persisted in a file whose absolute path can
// be specified via `-key_spaces_path`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Key spaces specification are just 4 integers, right? Why do we want to persist it in a file instead of providing it from cmd?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right.
I feel that the key spaces should be persisted across database restarts if destroy_db_initially is false. This is different from the ranges of keys that actually exist in the database, thus we cannot rely on checking the db for this info.

@facebook-github-bot
Copy link
Contributor

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

@riversand963
Copy link
Contributor Author

Thanks @jay-zhuang for the review!

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@riversand963 riversand963 deleted the config-txn-stress branch March 17, 2022 02:12
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