Skip to content

Commit

Permalink
Bug#33824058 NDB_BUG17624736 FAILS IN PB2 #1 [noclose]
Browse files Browse the repository at this point in the history
* PROBLEM

The test "ndb.ndb_bug17624736" was constantly failing in
[daily|weekly]-8.0-cluster branches in PB2, whether on `ndb-ps` or
`ndb-default-big` profile test runs. The high-level reason for the
failure was the installation of a duplicate entry in the Data
Dictionary in respect to the `engine`-`se_private_id` pair, even when
the previous table definition should have been dropped.

* LOW-LEVEL EXPLANATION

NDB reuses the least available ID for the dictionary table ID. The ID
is then used by the NDB plugin to install as SE private ID field of
the MySQL Data Dictionary table definition. If a problem occurs during
the synchronization of NDB table definitions in the Data
Dictionary (i.e., a previous definition was not successfully removed),
then an attempt to install a table using an already installed SE
private ID can occur. If that ID was inadvertedly cached as `missing`,
then the function `acquire_uncached_table_by_se_private_id` will
return fast without retrieving the table definition. Therefore, the
old table definition on that ID cannot be retrieved ever for that Data
Dictionary client instance, the new one won't be installed, and errors
will be raised.

* SOLUTION

For NDB plugin to query a table definition, using the SE private
ID (without causing a missing entry to be cached forever for that
client instance), this patch adds a flag argument to the function to
allow the caller to request it to skip the fast cache.

Change-Id: I45eef594ee544000fe6b30b86977e5e91155dc80
  • Loading branch information
dtcpatricio committed May 31, 2022
1 parent bb70858 commit 9b827eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
11 changes: 7 additions & 4 deletions sql/dd/cache/dictionary_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,11 @@ class Dictionary_client {
/**
Retrieve a table object by its se private id.
@param engine Name of the engine storing the table.
@param se_private_id SE private id of the table.
@param [out] table Table object, if present; otherwise NULL.
@param engine Name of the engine storing the table.
@param se_private_id SE private id of the table.
@param [out] table Table object, if present; otherwise NULL.
@param skip_spi_cache Optionally skip looking into the missing
SE private ID cache. Defaults to false.
@note The object must be acquired uncached since we cannot acquire a
metadata lock in advance since we do not know the table name.
Expand All @@ -801,7 +803,8 @@ class Dictionary_client {
*/

[[nodiscard]] bool acquire_uncached_table_by_se_private_id(
const String_type &engine, Object_id se_private_id, Table **table);
const String_type &engine, Object_id se_private_id, Table **table,
bool skip_spi_cache = false);

/**
Retrieve a table object by its partition se private id.
Expand Down
19 changes: 13 additions & 6 deletions sql/dd/impl/cache/dictionary_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1554,14 +1554,19 @@ bool Dictionary_client::acquire_for_modification(

// Retrieve a table object by its se private id.
bool Dictionary_client::acquire_uncached_table_by_se_private_id(
const String_type &engine, Object_id se_private_id, Table **table) {
const String_type &engine, Object_id se_private_id, Table **table,
bool skip_spi_cache) {
assert(table);
*table = nullptr;
bool no_table =
is_cached(m_no_table_spids, se_private_id, SPI_missing_type::TABLES);
bool no_table = false;

if (no_table) {
return false;
if (!skip_spi_cache) {
no_table =
is_cached(m_no_table_spids, se_private_id, SPI_missing_type::TABLES);

if (no_table) {
return false;
}
}

// Create se private key.
Expand All @@ -1579,7 +1584,9 @@ bool Dictionary_client::acquire_uncached_table_by_se_private_id(

// If object was not found.
if (stored_object == nullptr) {
m_no_table_spids->insert(se_private_id, SPI_missing_type::TABLES);
if (!skip_spi_cache) {
m_no_table_spids->insert(se_private_id, SPI_missing_type::TABLES);
}
return false;
}
assert(no_table == false);
Expand Down

0 comments on commit 9b827eb

Please sign in to comment.