Skip to content

Commit

Permalink
[flash-557]change branch of client-c (#275)
Browse files Browse the repository at this point in the history
* change branch of client-c

* add client-c

* retry get safepoint

* change for client-c

* update submodule

* Fix a clang flag

* address comments

* Remove questionable warning flags
  • Loading branch information
hanfei1991 authored Oct 14, 2019
1 parent 9fa88a2 commit 8fbd0f8
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 31 deletions.
2 changes: 1 addition & 1 deletion dbms/src/DataStreams/AdditionalColumnsBlockOutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <DataStreams/IBlockOutputStream.h>
#include <Core/ColumnsWithTypeAndName.h>
#include <pd/IClient.h>
#include <pingcap/pd/IClient.h>

namespace DB
{
Expand Down
33 changes: 33 additions & 0 deletions dbms/src/Storages/Transaction/PDTiKVClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <pingcap/pd/IClient.h>
#include <pingcap/kv/Backoff.h>

namespace DB
{

// TODO:: Implement Read Index Client;

struct PDClientHelper
{

static constexpr int get_safepoint_maxtime = 120000; // 120s. waiting pd recover.

static uint64_t getGCSafePointWithRetry(pingcap::pd::ClientPtr pd_client)
{
pingcap::kv::Backoffer bo(get_safepoint_maxtime);
for (;;)
{
try
{
auto safe_point = pd_client->getGCSafePoint();
return safe_point;
}
catch (pingcap::Exception & e)
{
bo.backoff(pingcap::kv::boPDRPC, e);
}
}
}
};


} // namespace DB
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/Region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <Storages/Transaction/RaftCommandResult.h>
#include <Storages/Transaction/Region.h>
#include <Storages/Transaction/TiKVRange.h>
#include <tikv/RegionClient.h>
#include <pingcap/kv/RegionClient.h>
#include <Storages/Transaction/RegionHelper.hpp>

namespace DB
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/RegionClientCreate.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <tikv/RegionClient.h>
#include <pingcap/kv/RegionClient.h>
#pragma GCC diagnostic pop

namespace DB
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/RegionMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <tikv/Region.h>
#include <pingcap/kv/Region.h>
#pragma GCC diagnostic pop

namespace DB
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/SchemaGetter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Storages/Transaction/Codec.h>
#include <Storages/Transaction/SchemaGetter.h>
#include <tikv/Scanner.h>
#include <pingcap/kv/Scanner.h>

namespace DB
{
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/SchemaGetter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <Storages/Transaction/TiDB.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <tikv/Snapshot.h>
#include <pingcap/kv/Snapshot.h>
#pragma GCC diagnostic pop

#include <common/logger_useful.h>
Expand Down
18 changes: 2 additions & 16 deletions dbms/src/Storages/Transaction/TMTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <Storages/Transaction/SchemaSyncer.h>
#include <Storages/Transaction/TMTContext.h>
#include <Storages/Transaction/TiDBSchemaSyncer.h>
#include <pd/MockPDClient.h>
#include <pingcap/pd/MockPDClient.h>

namespace DB
{
Expand Down Expand Up @@ -57,28 +57,14 @@ void TMTContext::setSchemaSyncer(SchemaSyncerPtr rhs)
schema_syncer = rhs;
}

pingcap::pd::ClientPtr TMTContext::getPDClient() const
{
std::lock_guard<std::mutex> lock(mutex);
return pd_client;
}

void TMTContext::setPDClient(pingcap::pd::ClientPtr rhs)
{
std::lock_guard<std::mutex> lock(mutex);
pd_client = rhs;
}
pingcap::pd::ClientPtr TMTContext::getPDClient() const { return pd_client; }

pingcap::kv::RegionClientPtr TMTContext::createRegionClient(pingcap::kv::RegionVerID region_version_id) const
{
std::lock_guard<std::mutex> lock(mutex);
return pd_client->isMock() ? nullptr : std::make_shared<pingcap::kv::RegionClient>(region_cache, rpc_client, region_version_id);
}

pingcap::kv::RegionCachePtr TMTContext::getRegionCache() const { return region_cache; }

pingcap::kv::RpcClientPtr TMTContext::getRpcClient() { return rpc_client; }

const std::unordered_set<std::string> & TMTContext::getIgnoreDatabases() const { return ignore_databases; }

} // namespace DB
7 changes: 1 addition & 6 deletions dbms/src/Storages/Transaction/TMTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <tikv/RegionClient.h>
#include <pingcap/kv/RegionClient.h>
#pragma GCC diagnostic pop

#include <unordered_set>
Expand Down Expand Up @@ -43,14 +43,9 @@ class TMTContext : private boost::noncopyable
void setSchemaSyncer(SchemaSyncerPtr);

pingcap::pd::ClientPtr getPDClient() const;
void setPDClient(pingcap::pd::ClientPtr);

pingcap::kv::RegionClientPtr createRegionClient(pingcap::kv::RegionVerID region_version_id) const;

pingcap::kv::RegionCachePtr getRegionCache() const;

pingcap::kv::RpcClientPtr getRpcClient();

void restore();

const std::unordered_set<std::string> & getIgnoreDatabases() const;
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/TiDBSchemaSyncer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <Debug/MockSchemaGetter.h>
#include <Storages/Transaction/SchemaBuilder.h>
#include <Storages/Transaction/TMTContext.h>
#include <tikv/Snapshot.h>
#include <pingcap/kv/Snapshot.h>

namespace DB
{
Expand Down
3 changes: 2 additions & 1 deletion dbms/src/Storages/Transaction/applySnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Storages/Transaction/Region.h>
#include <Storages/Transaction/RegionDataMover.h>
#include <Storages/Transaction/TMTContext.h>
#include <Storages/Transaction/PDTiKVClient.h>
#include <Storages/Transaction/applySnapshot.h>

namespace DB
Expand Down Expand Up @@ -39,7 +40,7 @@ bool applySnapshot(const KVStorePtr & kvstore, RegionPtr new_region, Context * c
if (context)
{
auto & tmt = context->getTMTContext();
Timestamp safe_point = tmt.getPDClient()->getGCSafePoint();
Timestamp safe_point = PDClientHelper::getGCSafePointWithRetry(tmt.getPDClient());

std::unordered_map<TableID, HandleMap> handle_maps;

Expand Down

0 comments on commit 8fbd0f8

Please sign in to comment.