Skip to content

Commit

Permalink
add debug function for force flushing all regions
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySon-Huang committed Sep 12, 2019
1 parent e2b2ca9 commit 5c7e00a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions dbms/src/Debug/dbgFuncRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ void dbgFuncPutRegion(Context & context, const ASTs & args, DBGInvoker::Printer
output(ss.str());
}

void dbgFuncTryFlush(Context & context, const ASTs &, DBGInvoker::Printer output)
void dbgFuncTryFlush(Context & context, const ASTs & args, DBGInvoker::Printer output)
{
TMTContext & tmt = context.getTMTContext();
tmt.getRegionTable().tryFlushRegions();

bool force_flush = false;
if (!args.empty())
force_flush = (String(typeid_cast<const ASTIdentifier &>(*args[1]).name) == "true");

tmt.getRegionTable().tryFlushRegions(force_flush);

std::stringstream ss;
ss << "region_table try flush regions";
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Debug/dbgFuncRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void dbgFuncDumpAllMockRegion(Context & context, const ASTs & args, DBGInvoker::

// Try flush regions
// Usage:
// ./storage-client.sh "DBGInvoke try_flush()"
// ./storage-client.sh "DBGInvoke try_flush([force_flush])"
void dbgFuncTryFlush(Context & context, const ASTs & args, DBGInvoker::Printer output);

// Try flush regions
Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Storages/Transaction/RegionTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,12 @@ void RegionTable::tryFlushRegion(RegionID region_id, TableID table_id)
std::rethrow_exception(first_exception);
}

bool RegionTable::tryFlushRegions()
bool RegionTable::tryFlushRegions(bool force)
{
std::map<std::pair<TableID, RegionID>, size_t> to_flush;
{ // judge choose region to flush
traverseInternalRegions([&](TableID table_id, InternalRegion & region) {
if (shouldFlush(region))
if (shouldFlush(region) || force)
{
to_flush.insert_or_assign({table_id, region.region_id}, region.cache_bytes);
// Stop other flush threads.
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/RegionTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class RegionTable : private boost::noncopyable
/// Note that flush is organized by partition. i.e. if a regions is selected to be flushed, all regions belong to its partition will also flushed.
/// This function will be called constantly by background threads.
/// Returns whether this function has done any meaningful job.
bool tryFlushRegions();
bool tryFlushRegions(bool force = false);

void tryFlushRegion(RegionID region_id);
void tryFlushRegion(RegionID region_id, TableID table_id);
Expand Down

0 comments on commit 5c7e00a

Please sign in to comment.