Skip to content

Simplified locking in sha256 tests by using GET_LOCK #411

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

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 1 addition & 7 deletions test/integration/db_setup_sha256.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,4 @@ ALTER USER 'csha2p_empty_password_user'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'csha2p_empty_password_user'@'%';


-- caching_sha2_password behaves differently on sha256 cache hit and miss.
-- These tests require exclusive access to the cache, and lock this table
-- to avoid race conditions (e.g. between concurrent b2 runs)
DROP TABLE IF EXISTS sha256_mutex;
CREATE TABLE sha256_mutex (dummy INT);

FLUSH PRIVILEGES;
FLUSH PRIVILEGES;
8 changes: 4 additions & 4 deletions test/integration/test/handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ BOOST_FIXTURE_TEST_CASE(tcp_connection_, tcp_connection_fixture)

BOOST_AUTO_TEST_SUITE_END() // mysql_native_password

// caching_sha2_password. We acquire a lock on the sha256_mutex
// (dummy table, used as a mutex) to avoid race conditions with other test runs
// caching_sha2_password. We acquire a named lock
// to avoid race conditions with other test runs
// (which happens in b2 builds).
// The sha256 cache is shared between all clients.
struct caching_sha2_lock : any_connection_fixture
Expand All @@ -177,9 +177,9 @@ struct caching_sha2_lock : any_connection_fixture
conn.async_connect(connect_params_builder().credentials("root", "").build(), as_netresult)
.validate_no_error();

// Acquire the lock
// Acquire the lock. -1 = no timeout
results r;
conn.async_execute("LOCK TABLE sha256_mutex WRITE", r, as_netresult).validate_no_error();
conn.async_execute("DO GET_LOCK('sha256_cache', -1)", r, as_netresult).validate_no_error();

// The lock is released on fixture destruction, when the connection is closed
}
Expand Down