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

Fix DeltaMerge CI #350

Merged
merged 6 commits into from
Dec 12, 2019
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
7 changes: 4 additions & 3 deletions dbms/src/Parsers/ASTInsertQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class ASTInsertQuery : public IAST
const char * data = nullptr;
const char * end = nullptr;

bool is_import;
bool is_upsert;
bool is_delete;
// If insert block is synced from TiDB, set is_import = true
bool is_import = false;
bool is_upsert = false;
bool is_delete = false;

/** Get the text that identifies this element. */
String getID() const override { return "InsertQuery_" + database + "_" + table; };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>
#include <memory>
#include <test_utils/TiflashTestBasic.h>
#include "dm_basic_include.h"

#include <Poco/ConsoleChannel.h>
Expand All @@ -22,7 +23,7 @@ namespace tests
class DeltaMergeStore_test : public ::testing::Test
{
public:
DeltaMergeStore_test() : name("tmp"), path("./" + name) {}
DeltaMergeStore_test() : name("tmp"), path(DB::tests::TiFlashTestEnv::getTemporaryPath() + name) {}

protected:
static void SetUpTestCase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace tests
class DiskValueSpace_test : public ::testing::Test
{
public:
DiskValueSpace_test() : name("tmp"), path("./" + name), storage_pool() {}
DiskValueSpace_test() : name("tmp"), path(DB::tests::TiFlashTestEnv::getTemporaryPath() +name), storage_pool() {}

private:
void dropDataInDisk()
Expand Down
5 changes: 3 additions & 2 deletions dbms/src/Storages/DeltaMerge/tests/gtest_dm_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using DMFileBlockInputStreamPtr = std::shared_ptr<DMFileBlockInputStream>;
class DMFile_Test : public ::testing::Test
{
public:
DMFile_Test() : path("tmp"), dm_file(nullptr) {}
DMFile_Test() : path(DB::tests::TiFlashTestEnv::getTemporaryPath() + "/dm_file_tests"), dm_file(nullptr) {}

void SetUp() override
{
Expand Down Expand Up @@ -55,7 +55,8 @@ class DMFile_Test : public ::testing::Test
db_context->getSettingsRef().dm_segment_limit_rows,
db_context->getSettingsRef().dm_segment_delta_limit_rows,
db_context->getSettingsRef().dm_segment_delta_cache_limit_rows,
db_context->getSettingsRef().dm_segment_stable_chunk_rows);
db_context->getSettingsRef().dm_segment_stable_chunk_rows,
db_context->getSettingsRef().dm_enable_logical_split);
}


Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/tests/gtest_dm_segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace tests
class Segment_test : public ::testing::Test
{
public:
Segment_test() : name("tmp"), path("./" + name), storage_pool() {}
Segment_test() : name("tmp"), path(DB::tests::TiFlashTestEnv::getTemporaryPath() + name), storage_pool() {}

private:
void dropDataInDisk()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <gtest/gtest.h>
#include <limits>
#include "dm_basic_include.h"

#include <Columns/IColumn.h>
Expand Down Expand Up @@ -85,7 +86,7 @@ try
column_names.push_back(name_type.name);
}

const String path_name = "tmp/";
const String path_name = DB::tests::TiFlashTestEnv::getTemporaryPath();
Poco::File path(path_name);
if (path.exists())
path.remove(true);
Expand Down Expand Up @@ -194,7 +195,7 @@ try
column_names.push_back(name_type.name);
}

const String path_name = "tmp/";
const String path_name = DB::tests::TiFlashTestEnv::getTemporaryPath();
Poco::File path(path_name);
if (path.exists())
path.remove(true);
Expand Down Expand Up @@ -231,7 +232,7 @@ try
query_info.query = std::make_shared<ASTSelectQuery>();
query_info.mvcc_query_info = std::make_unique<MvccQueryInfo>();
query_info.mvcc_query_info->resolve_locks = global_ctx.getSettingsRef().resolve_locks;
query_info.mvcc_query_info->read_tso = global_ctx.getSettingsRef().read_tso;
query_info.mvcc_query_info->read_tso = std::numeric_limits<UInt64>::max();
BlockInputStreams ins = storage->read(column_names, query_info, global_ctx, stage2, 8192, 1);
ASSERT_EQ(ins.size(), 1UL);
BlockInputStreamPtr in = ins[0];
Expand Down
3 changes: 2 additions & 1 deletion dbms/src/Storages/Page/tests/gtest_page_storage.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "gtest/gtest.h"
#include <test_utils/TiflashTestBasic.h>

#include <Common/CurrentMetrics.h>
#include <IO/ReadBufferFromMemory.h>
Expand Down Expand Up @@ -27,7 +28,7 @@ namespace tests
class PageStorage_test : public ::testing::Test
{
public:
PageStorage_test() : path("./t"), storage() {}
PageStorage_test() : path(DB::tests::TiFlashTestEnv::getTemporaryPath() + "/page_storage_test"), storage() {}

protected:
static void SetUpTestCase()
Expand Down
17 changes: 12 additions & 5 deletions dbms/src/Storages/StorageDeltaMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,19 @@ BlockInputStreams StorageDeltaMerge::read( //
throw Exception("TMTContext is not initialized", ErrorCodes::LOGICAL_ERROR);

const auto & mvcc_query_info = *query_info.mvcc_query_info;

// Read with specify tso, check if tso is smaller than TiDB GcSafePoint
const auto safe_point = tmt.getPDClient()->getGCSafePoint();
if (mvcc_query_info.read_tso < safe_point)
throw Exception("query id: " + context.getCurrentQueryId() + ", read tso: " + toString(mvcc_query_info.read_tso)
+ " is smaller than tidb gc safe point: " + toString(safe_point),
ErrorCodes::LOGICAL_ERROR);
auto pd_client = tmt.getPDClient();
if (likely(!pd_client->isMock()))
{
auto safe_point = PDClientHelper::getGCSafePointWithRetry(pd_client,
/* ignore_cache= */ false,
global_context.getSettingsRef().safe_point_update_interval_seconds);
if (mvcc_query_info.read_tso < safe_point)
throw Exception("query id: " + context.getCurrentQueryId() + ", read tso: " + toString(mvcc_query_info.read_tso)
+ " is smaller than tidb gc safe point: " + toString(safe_point),
ErrorCodes::LOGICAL_ERROR);
}

/// If request comes from TiDB/TiSpark, mvcc_query_info.concurrent is 0,
/// and `concurrent_num` should be 1. Concurrency handled by TiDB/TiSpark.
Expand Down
6 changes: 4 additions & 2 deletions dbms/src/test_utils/TiflashTestBasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ namespace tests
class TiFlashTestEnv
{
public:
static String getTemporaryPath() { return "./tmp/"; }

static Context & getContext(const DB::Settings & settings = DB::Settings())
{
static Context context = DB::Context::createGlobal();
context.setPath(".");
context.setPath(getTemporaryPath());
context.setGlobalContext(context);
try
{
Expand All @@ -28,7 +30,7 @@ class TiFlashTestEnv
context.setGlobalContext(context);
context.setApplicationType(DB::Context::ApplicationType::SERVER);

context.createTMTContext({}, "", "", {"default"}, "./tmp/kvstore", "", TiDB::StorageEngine::TMT, false);
context.createTMTContext({}, "", "", {"default"}, getTemporaryPath() + "/kvstore", "", TiDB::StorageEngine::TMT, false);
context.getTMTContext().restore();
}
context.getSettingsRef() = settings;
Expand Down