Closed shishir2001-yb closed 7 months ago
I think this is an expected error. The following is the relevant code.
In
Status Tablet::DoHandlePgsqlReadRequest(
We have
// Assert the table is a Postgres table.
DCHECK_EQ(table_info->table_type, TableType::PGSQL_TABLE_TYPE);
if (table_info->schema_version != pgsql_read_request.schema_version()) {
result->response.Clear();
result->response.set_status(PgsqlResponsePB::PGSQL_STATUS_SCHEMA_VERSION_MISMATCH);
result->response.set_error_message(
Format("schema version mismatch for table $0: expected $1, got $2",
table_info->table_id,
table_info->schema_version,
pgsql_read_request.schema_version()));
return Status::OK();
}
From the above code, in order to detect schema version mismatch error, we must
have a valid table_info
for the given table. That means the table isn’t deleted
yet at this tserver.
If the table is deleted, then earlier in the above function DoHandlePgsqlReadRequest
const shared_ptr<tablet::TableInfo> table_info =
VERIFY_RESULT(metadata_->GetTableInfo(pgsql_read_request.table_id()));
would have returned an error. In other words, VERIFY_RESULT
will cause the
function to return an error status indicating the details of the error. So
GetTableInfo
can fail to find the table_id()
from the pgsql_read_request
.
Result<TableInfoPtr> RaftGroupMetadata::GetTableInfo(const TableId& table_id) const {
std::lock_guard lock(data_mutex_);
return GetTableInfoUnlocked(table_id);
}
Result<TableInfoPtr> RaftGroupMetadata::GetTableInfoUnlocked(const TableId& table_id) const {
const auto& tables = kv_store_.tables;
const auto& id = !table_id.empty() ? table_id : primary_table_id_;
const auto iter = tables.find(id);
if (iter == tables.end()) {
RETURN_TABLE_NOT_FOUND(table_id, tables);
}
return iter->second;
}
We can see that RETURN_TABLE_NOT_FOUND
is used to report error if the table is
not found.
#define RETURN_TABLE_NOT_FOUND(table_id, tables) \
return MakeTableNotFound((table_id), raft_group_id_, (tables), __FILE__, __LINE__)
template <class TablesMap>
Status MakeTableNotFound(const TableId& table_id, const RaftGroupId& raft_group_id,
const TablesMap& tables, const char* file_name, int line_number) {
std::string table_name = "<unknown_table_name>";
if (!table_id.empty()) {
const auto iter = tables.find(table_id);
if (iter != tables.end()) {
table_name = iter->second->table_name;
}
}
std::ostringstream string_stream;
string_stream << "Table " << table_name << " (" << table_id << ") not found in Raft group "
<< raft_group_id;
std::string msg = string_stream.str();
#ifndef NDEBUG
// This very large message should be logged instead of being appended to STATUS.
std::string suffix = Format(". Tables: $0.", tables);
VLOG(1) << msg << suffix;
#endif
return Status(Status::kNotFound, file_name, line_number, msg);
}
So not found in Raft group
, the error we see in 21200, it’s the same nature
error as a schema version mismatch
. It’s just that the former happens when the
table is deleted, while the latter happens when the table still exists but is
altered. I say same nature because in both cases, the table is changed.
I think we should add not found in Raft group
into the list of
allowedDMLExceptions
in the sample app because this error can legimitately
appear when a table is deleted concurrently while the DML statement is
executing.
Resolving as by design per above explanation.
Jira Link: DB-10130
Description
Tried on version: 2.21.1.0-b124
Logs: https://drive.google.com/file/d/1bNVlhO6rXE6AM7l1f7NMYgjKfa5S2iU_/view?usp=sharing
Insert query fails with the below error while running Cross-DB-DDL sample app.
Sample app details:
List of DDLs executed in sample app
Issue Type
kind/bug
Warning: Please confirm that this issue does not contain any sensitive information