-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENG-2964: Allow flushing all tablets of a given table
Summary: Implementing ability to flush tablets mem-stores. Test Plan: yb-admin-test Reviewers: sergei, timur, mikhail, pritam.damania Reviewed By: mikhail, pritam.damania Subscribers: bogdan, ybase, bharat Differential Revision: https://phabricator.dev.yugabyte.com/D4191
- Loading branch information
1 parent
a4498b4
commit 4902d06
Showing
32 changed files
with
919 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright (c) YugaByte, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed under the License | ||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
#include "yb/master/async_flush_tablets_task.h" | ||
|
||
#include "yb/common/wire_protocol.h" | ||
|
||
#include "yb/master/master.h" | ||
#include "yb/master/ts_descriptor.h" | ||
#include "yb/master/flush_manager.h" | ||
#include "yb/master/catalog_manager.h" | ||
|
||
#include "yb/rpc/messenger.h" | ||
|
||
#include "yb/tserver/tserver_admin.proxy.h" | ||
|
||
#include "yb/util/flag_tags.h" | ||
#include "yb/util/format.h" | ||
#include "yb/util/logging.h" | ||
|
||
namespace yb { | ||
namespace master { | ||
|
||
using std::string; | ||
using tserver::TabletServerErrorPB; | ||
|
||
//////////////////////////////////////////////////////////// | ||
// AsyncFlushTablets | ||
//////////////////////////////////////////////////////////// | ||
AsyncFlushTablets::AsyncFlushTablets(Master *master, | ||
ThreadPool* callback_pool, | ||
const TabletServerId& ts_uuid, | ||
const scoped_refptr<TableInfo>& table, | ||
const vector<TabletId>& tablet_ids, | ||
const FlushRequestId& flush_id) | ||
: RetrySpecificTSRpcTask(master, callback_pool, ts_uuid, table), | ||
tablet_ids_(tablet_ids), | ||
flush_id_(flush_id) { | ||
} | ||
|
||
string AsyncFlushTablets::description() const { | ||
return Format("$0 Flush Tablets RPC", permanent_uuid()); | ||
} | ||
|
||
TabletServerId AsyncFlushTablets::permanent_uuid() const { | ||
return permanent_uuid_; | ||
} | ||
|
||
void AsyncFlushTablets::HandleResponse(int attempt) { | ||
server::UpdateClock(resp_, master_->clock()); | ||
|
||
if (resp_.has_error()) { | ||
Status status = StatusFromPB(resp_.error().status()); | ||
|
||
// Do not retry on a fatal error. | ||
switch (resp_.error().code()) { | ||
case TabletServerErrorPB::TABLET_NOT_FOUND: | ||
LOG(WARNING) << "TS " << permanent_uuid() << ": flush tablets failed because tablet " | ||
<< resp_.failed_tablet_id() << " was not found. " | ||
<< "No further retry: " << status.ToString(); | ||
PerformStateTransition(kStateRunning, kStateComplete); | ||
break; | ||
default: | ||
LOG(WARNING) << "TS " << permanent_uuid() << ": flush tablets failed: " | ||
<< status.ToString(); | ||
} | ||
} else { | ||
PerformStateTransition(kStateRunning, kStateComplete); | ||
VLOG(1) << "TS " << permanent_uuid() << ": flush tablets complete"; | ||
} | ||
|
||
if (state() == kStateComplete) { | ||
// TODO: this class should not know CatalogManager API, | ||
// remove circular dependency between classes. | ||
master_->flush_manager()->HandleFlushTabletsResponse( | ||
flush_id_, permanent_uuid_, | ||
resp_.has_error() ? StatusFromPB(resp_.error().status()) : Status::OK()); | ||
} else { | ||
VLOG(1) << "FlushTablets task is not completed"; | ||
} | ||
} | ||
|
||
bool AsyncFlushTablets::SendRequest(int attempt) { | ||
tserver::FlushTabletsRequestPB req; | ||
req.set_dest_uuid(permanent_uuid_); | ||
req.set_propagated_hybrid_time(master_->clock()->Now().ToUint64()); | ||
|
||
for (const TabletId& id : tablet_ids_) { | ||
req.add_tablet_ids(id); | ||
} | ||
|
||
ts_admin_proxy_->FlushTabletsAsync(req, &resp_, &rpc_, BindRpcCallback()); | ||
VLOG(1) << "Send flush tablets request to " << permanent_uuid_ | ||
<< " (attempt " << attempt << "):\n" | ||
<< req.DebugString(); | ||
return true; | ||
} | ||
|
||
} // namespace master | ||
} // namespace yb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) YugaByte, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed under the License | ||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
#ifndef YB_MASTER_ASYNC_FLUSH_TABLETS_TASK_H | ||
#define YB_MASTER_ASYNC_FLUSH_TABLETS_TASK_H | ||
|
||
#include "yb/master/async_rpc_tasks.h" | ||
|
||
namespace yb { | ||
namespace master { | ||
|
||
// Send the "Flush Tablets" request to the specified Tablet Server. | ||
// Keeps retrying until we get an "ok" response. | ||
class AsyncFlushTablets : public RetrySpecificTSRpcTask { | ||
public: | ||
AsyncFlushTablets(Master* master, | ||
ThreadPool* callback_pool, | ||
const TabletServerId& ts_uuid, | ||
const scoped_refptr<TableInfo>& table, | ||
const std::vector<TabletId>& tablet_ids, | ||
const FlushRequestId& flush_id); | ||
|
||
Type type() const override { return ASYNC_FLUSH_TABLETS; } | ||
|
||
std::string type_name() const override { return "Flush Tablets"; } | ||
|
||
std::string description() const override; | ||
|
||
private: | ||
TabletId tablet_id() const override { return TabletId(); } | ||
TabletServerId permanent_uuid() const; | ||
|
||
void HandleResponse(int attempt) override; | ||
bool SendRequest(int attempt) override; | ||
|
||
const std::vector<TabletId> tablet_ids_; | ||
const FlushRequestId flush_id_; | ||
tserver::FlushTabletsResponsePB resp_; | ||
}; | ||
|
||
} // namespace master | ||
} // namespace yb | ||
|
||
#endif // YB_MASTER_ASYNC_FLUSH_TABLETS_TASK_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.