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

Make MyRocks DD commits always durable #1403

Conversation

laurynas-biveinis
Copy link
Contributor

@laurynas-biveinis laurynas-biveinis commented Dec 4, 2023

Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag Rdb_transaction::m_dd_transaction, which is set in ha_rocksdb::external_lock and checked in rocksdb_prepare. To avoid confusion, rename the existing m_ddl_transaction flag to m_bulk_index_transaction.

@facebook-github-bot
Copy link

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

@luqun
Copy link
Contributor

luqun commented Dec 7, 2023

how about check thd_is_dd_update_stmt() during trx prepare(or m_ddl_transaction = thd_is_dd_update_stmt(thd))? so that we have similar behavior as innodb?

such as

  if (thd_is_dd_update_stmt(thd)) {
    tx->set_sync(true);
    
    or 
    
    m_ddl_transaction = thd_is_dd_update_stmt(thd);
    
    Related innodb code: https://github.com/facebook/mysql-5.6/blob/fb-mysql-8.0.32/storage/innobase/trx/trx0trx.cc#L2034

@laurynas-biveinis
Copy link
Contributor Author

laurynas-biveinis commented Dec 15, 2023

how about check thd_is_dd_update_stmt() during trx prepare(or m_ddl_transaction = thd_is_dd_update_stmt(thd))?

Unfortunately thd_is_dd_update_stmt is true in fewer instances than ha_rocksdb::external_lock(F_WRLCK) is called on a table with a DD category and making this change re-introduces crash recovery test failures. For InnoDB, thd_is_dd_update_stmt is also not the only input for trx->ddl_operation.

Some examples of queries where the two differ, test rocksdb_dd_innodb.ddl_crash_basic:

Mismatch in external_lock: table_share->table_category == TABLE_CATEGORY_DICTIONARY = 1, thd_is_dd_update_stmt() = 1, query = OPTIMIZE TABLE t1
Mismatch in rocksdb_prepare: is_dd_update = 0, tx->is_dd_transaction() = 1, query = OPTIMIZE TABLE t1
Mismatch in external_lock: table_share->table_category == TABLE_CATEGORY_DICTIONARY = 1, thd_is_dd_update_stmt() = 1, query = DROP TABLE t1
Mismatch in rocksdb_prepare: is_dd_update = 0, tx->is_dd_transaction() = 1, query = DROP TABLE t1
Mismatch in external_lock: table_share->table_category == TABLE_CATEGORY_DICTIONARY = 1, thd_is_dd_update_stmt() = 1, query = CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd'
Mismatch in rocksdb_prepare: is_dd_update = 0, tx->is_dd_transaction() = 1, query = CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd'
Mismatch in external_lock: table_share->table_category == TABLE_CATEGORY_DICTIONARY = 1, thd_is_dd_update_stmt() = 1, query = ALTER TABLESPACE ts1 RENAME TO ts1_renamed
Mismatch in external_lock: table_share->table_category == TABLE_CATEGORY_DICTIONARY = 1, thd_is_dd_update_stmt() = 1, query = ALTER TABLESPACE ts1 RENAME TO ts1_renamed
Mismatch in rocksdb_prepare: is_dd_update = 0, tx->is_dd_transaction() = 1, query = ALTER TABLESPACE ts1 RENAME TO ts1_renamed

@laurynas-biveinis
Copy link
Contributor Author

laurynas-biveinis commented Dec 15, 2023

There are also some cases where thd_is_dd_update_stmt is set, but no DD table is write-locked in MyRocks: CREATE EVENT event_t1 ... which accesses a system, not a DD table.

Regular commit durability is governed by the binlog group commit algorithm and
system variables. Make any commits (and prepares in 2PC) involving DD tables
always durable unconditionally, just like InnoDB does. It is implemented through
a new flag Rdb_transaction::m_dd_transaction, which is set in
ha_rocksdb::external_lock and checked in rocksdb_prepare. To avoid confusion,
rename the existing m_ddl_transaction flag to m_bulk_index_transaction. At the
same time tweak ha_rocksdb::is_dd_update to downgrade the DD/system engine check
to an assert.
@facebook-github-bot
Copy link

@laurynas-biveinis has updated the pull request. You must reimport the pull request before landing.

@laurynas-biveinis
Copy link
Contributor Author

@luqun, rebased with no substantial changes (for now?), added a small tweak to ha_rocksdb::is_dd_update not to check default_dd_system_storage_engine.

@facebook-github-bot
Copy link

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

facebook-github-bot pushed a commit that referenced this pull request Dec 20, 2023
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: #1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
@laurynas-biveinis laurynas-biveinis deleted the myr-durable-dd-commit branch December 20, 2023 06:05
sunxiayi pushed a commit to sunxiayi/mysql-5.6 that referenced this pull request Apr 30, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403
GitHub Author: Laurynas Biveinis <laurynas.biveinis@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.

Reviewers: herman, chni, #mysql_eng

Reviewed By: chni

Differential Revision: https://phabricator.intern.facebook.com/D51872251
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 13, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 15, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 16, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 17, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 17, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 21, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 21, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request May 30, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Jul 19, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Jul 19, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Jul 30, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Jul 31, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Aug 2, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
inikep pushed a commit to inikep/mysql-5.6 that referenced this pull request Aug 6, 2024
Summary:
Regular commit durability is governed by the binlog group commit algorithm and system variables. Make any commits (and prepares in 2PC) involving DD tables always durable unconditionally, just like InnoDB does. It is implemented through a new flag `Rdb_transaction::m_dd_transaction`, which is set in `ha_rocksdb::external_lock` and checked in `rocksdb_prepare`. To avoid confusion, rename the existing `m_ddl_transaction` flag to `m_bulk_index_transaction`.

Pull Request resolved: facebook#1403

Differential Revision: D51872251

fbshipit-source-id: 64290c8
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.

None yet

3 participants