Skip to content

Commit

Permalink
Remove useless storage engine type setting
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySon-Huang committed Aug 21, 2024
1 parent 69c7428 commit 20e5abf
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 62 deletions.
5 changes: 1 addition & 4 deletions dbms/src/Debug/MockTiDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,7 @@ TiDB::TableInfoPtr MockTiDB::parseColumns(
std::transform(engine_type.begin(), engine_type.end(), engine_type.begin(), [](unsigned char c) {
return std::tolower(c);
});
if (engine_type == "dt")
table_info.engine_type = TiDB::StorageEngine::DT;

if (table_info.engine_type != TiDB::StorageEngine::DT)
if (engine_type != "dt")
{
throw Exception("Unknown engine type : " + engine_type + ", must be 'dt'", ErrorCodes::BAD_ARGUMENTS);
}
Expand Down
4 changes: 0 additions & 4 deletions dbms/src/Debug/dbgFuncMockTiDBTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ void MockTiDBTable::dbgFuncMockTiDBTable(Context & context, const ASTs & args, D
= InterpreterCreateQuery::getColumnsDescription(typeid_cast<const ASTExpressionList &>(*columns_ast), context);

String engine_type("dt");
if (context.getTMTContext().getEngineType() == ::TiDB::StorageEngine::TMT)
engine_type = "tmt";
if (args.size() == 5)
engine_type = safeGet<String>(typeid_cast<const ASTLiteral &>(*args[4]).value);

Expand Down Expand Up @@ -355,8 +353,6 @@ void MockTiDBTable::dbgFuncCreateTiDBTables(Context & context, const ASTs & args
}
auto tso = context.getTMTContext().getPDClient()->getTS();
String engine_type("dt");
if (context.getTMTContext().getEngineType() == ::TiDB::StorageEngine::TMT)
engine_type = "tmt";
MockTiDB::instance().newTables(database_name, tables, tso, engine_type);
output("");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class InterperCreateQueryTiFlashTest : public ::testing::Test

TiDB::DBInfo db_info(db_info_json, NullspaceID);
TiDB::TableInfo table_info(table_info_json, NullspaceID);
table_info.engine_type = ::TiDB::StorageEngine::DT;

ParserCreateQuery parser;
ASTPtr ast
Expand Down Expand Up @@ -167,4 +166,4 @@ try
}
CATCH
} // namespace tests
} // namespace DB
} // namespace DB
1 change: 0 additions & 1 deletion dbms/src/Server/DTTool/DTTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class ImitativeEnv
global_context->initializeGlobalPageIdAllocator();
global_context->initializeGlobalStoragePoolIfNeed(global_context->getPathPool());
raft_config.ignore_databases = {"default", "system"};
raft_config.engine = TiDB::StorageEngine::DT;
global_context->createTMTContext(raft_config, pingcap::ClusterConfig());

global_context->setDeltaIndexManager(1024 * 1024 * 100 /*100MB*/);
Expand Down
14 changes: 0 additions & 14 deletions dbms/src/Server/RaftConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,6 @@ TiFlashRaftConfig TiFlashRaftConfig::parseSettings(Poco::Util::AbstractConfigura
LOG_INFO(log, "Found ignore databases: {}", fmt_buf.toString());
}

if (config.has("raft.storage_engine"))
{
String s_engine = config.getString("raft.storage_engine");
std::transform(s_engine.begin(), s_engine.end(), s_engine.begin(), [](char ch) { return std::tolower(ch); });
if (s_engine == "tmt")
res.engine = ::TiDB::StorageEngine::TMT;
else if (s_engine == "dt")
res.engine = ::TiDB::StorageEngine::DT;
else
res.engine = DEFAULT_ENGINE;
}

LOG_INFO(log, "Default storage engine [type={}]", static_cast<Int64>(res.engine));

return res;
}

Expand Down
3 changes: 0 additions & 3 deletions dbms/src/Server/RaftConfigParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ struct TiFlashRaftConfig

bool for_unit_test = false;

static constexpr TiDB::StorageEngine DEFAULT_ENGINE = TiDB::StorageEngine::DT;
TiDB::StorageEngine engine = DEFAULT_ENGINE;

public:
TiFlashRaftConfig() = default;

Expand Down
1 change: 0 additions & 1 deletion dbms/src/Storages/KVStore/TMTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ TMTContext::TMTContext(
context.getSettingsRef().task_scheduler_thread_soft_limit,
context.getSettingsRef().task_scheduler_thread_hard_limit,
context.getSettingsRef().task_scheduler_active_set_soft_limit)))
, engine(raft_config.engine)
, batch_read_index_timeout_ms(DEFAULT_BATCH_READ_INDEX_TIMEOUT_MS)
, wait_index_timeout_ms(DEFAULT_WAIT_INDEX_TIMEOUT_MS)
, read_index_worker_tick_ms(DEFAULT_READ_INDEX_WORKER_TICK_MS)
Expand Down
4 changes: 0 additions & 4 deletions dbms/src/Storages/KVStore/TMTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ class TMTContext : private boost::noncopyable

const std::unordered_set<std::string> & getIgnoreDatabases() const;

::TiDB::StorageEngine getEngineType() const { return engine; }

void reloadConfig(const Poco::Util::AbstractConfiguration & config);

bool isInitialized() const;
Expand Down Expand Up @@ -172,8 +170,6 @@ class TMTContext : private boost::noncopyable
std::shared_ptr<TiDBSchemaSyncerManager> schema_sync_manager;
MPPTaskManagerPtr mpp_task_manager;

::TiDB::StorageEngine engine;

std::atomic_uint64_t batch_read_index_timeout_ms;
std::atomic_uint64_t wait_index_timeout_ms;
std::atomic_uint64_t read_index_worker_tick_ms;
Expand Down
1 change: 0 additions & 1 deletion dbms/src/TestUtils/TiFlashTestEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ void TiFlashTestEnv::addGlobalContext(
TiFlashRaftConfig raft_config;

raft_config.ignore_databases = {"system"};
raft_config.engine = TiDB::StorageEngine::DT;
raft_config.for_unit_test = true;
global_context->createTMTContext(raft_config, pingcap::ClusterConfig());

Expand Down
33 changes: 8 additions & 25 deletions dbms/src/TiDB/Schema/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,27 +1089,16 @@ String createTableStmt(
writeString(columns[i].type->getName(), stmt_buf);
}

// storage engine type
if (table_info.engine_type == TiDB::StorageEngine::DT)
writeString(") Engine = DeltaMerge((", stmt_buf);
for (size_t i = 0; i < pks.size(); i++)
{
writeString(") Engine = DeltaMerge((", stmt_buf);
for (size_t i = 0; i < pks.size(); i++)
{
if (i > 0)
writeString(", ", stmt_buf);
writeBackQuotedString(pks[i], stmt_buf);
}
writeString("), '", stmt_buf);
writeEscapedString(table_info.serialize(), stmt_buf);
writeString(fmt::format("', {})", tombstone), stmt_buf);
}
else
{
throw TiFlashException(
Errors::DDL::Internal,
"Unknown engine type : {}",
fmt::underlying(table_info.engine_type));
if (i > 0)
writeString(", ", stmt_buf);
writeBackQuotedString(pks[i], stmt_buf);
}
writeString("), '", stmt_buf);
writeEscapedString(table_info.serialize(), stmt_buf);
writeString(fmt::format("', {})", tombstone), stmt_buf);

return stmt;
}
Expand Down Expand Up @@ -1138,12 +1127,6 @@ void SchemaBuilder<Getter, NameMapper>::applyCreateStorageInstance(
return;
}
// Else the storage instance does not exist, create it.
/// Normal CREATE table.
if (table_info->engine_type == StorageEngine::UNSPECIFIED)
{
auto & tmt_context = context.getTMTContext();
table_info->engine_type = tmt_context.getEngineType();
}

// We need to create a Storage instance to handle its raft log and snapshot when it
// is "dropped" but not physically removed in TiDB. To handle it porperly, we get a
Expand Down
2 changes: 0 additions & 2 deletions dbms/src/TiDB/Schema/TiDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ struct TableInfo
// The TiFlash replica info persisted by TiDB
TiFlashReplicaInfo replica_info;

TiDB::StorageEngine engine_type = TiDB::StorageEngine::UNSPECIFIED; // TODO(hyy):seems could be removed

ColumnID getColumnID(const String & name) const;
String getColumnName(ColumnID id) const;
KeyspaceID getKeyspaceID() const;
Expand Down
1 change: 0 additions & 1 deletion dbms/src/TiDB/Schema/tests/gtest_table_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ struct StmtCase
EXPECT_EQ(json1, json2) << "Table info unescaped serde mismatch:\n" + json1 + "\n" + json2;

// generate create statement with db_info and table_info
table_info.engine_type = TiDB::StorageEngine::DT;
String stmt = createTableStmt(
db_info.keyspace_id,
db_info.id,
Expand Down

0 comments on commit 20e5abf

Please sign in to comment.