Snapshot flags name consistency
Reviewers: buda, mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D821
This commit is contained in:
parent
e224199b36
commit
ff37c04b38
@ -21,17 +21,16 @@
|
||||
--snapshot-cycle-sec=300
|
||||
|
||||
# create snapshot disabled on db exit
|
||||
--snapshot-on-db-exit=true
|
||||
--snapshot-on-exit=true
|
||||
|
||||
# max number of snapshots which will be kept on the disk at some point
|
||||
# if set to -1 the max number of snapshots is unlimited
|
||||
--max-retained-snapshots=3
|
||||
--snapshot-max-retained=3
|
||||
|
||||
# by default query engine runs in interpret mode
|
||||
--interpret=true
|
||||
|
||||
# database recovering is disabled by default
|
||||
--recover-on-startup=true
|
||||
--snapshot-recover-on-startup=true
|
||||
|
||||
# use ast caching
|
||||
--ast-cache=false
|
||||
|
@ -29,17 +29,17 @@
|
||||
--query_execution_time_sec=-1
|
||||
|
||||
# create snapshot disabled on db exit
|
||||
--snapshot-on-db-exit=false
|
||||
--snapshot-on-exit=false
|
||||
|
||||
# max number of snapshots which will be kept on the disk at some point
|
||||
# if set to -1 the max number of snapshots is unlimited
|
||||
--max-retained-snapshots=-1
|
||||
--snapshot-max-retained=-1
|
||||
|
||||
# by default query engine runs in interpret mode
|
||||
--interpret=true
|
||||
|
||||
# database recovering is disabled by default
|
||||
--recover-on-startup=false
|
||||
--snapshot-recover-on-startup=false
|
||||
|
||||
# use ast caching
|
||||
--ast-cache=true
|
||||
|
@ -21,17 +21,17 @@
|
||||
--query_execution_time_sec=-1
|
||||
|
||||
# create snapshot disabled on db exit
|
||||
--snapshot-on-db-exit=false
|
||||
--snapshot-on-exit=false
|
||||
|
||||
# max number of snapshots which will be kept on the disk at some point
|
||||
# if set to -1 the max number of snapshots is unlimited
|
||||
--max-retained-snapshots=-1
|
||||
--snapshot-max-retained=-1
|
||||
|
||||
# by default query engine runs in interpret mode
|
||||
--interpret=true
|
||||
|
||||
# database recovering is disabled by default
|
||||
--recover-on-startup=false
|
||||
--snapshot-recover-on-startup=false
|
||||
|
||||
# use ast caching
|
||||
--ast-cache=true
|
||||
|
@ -21,17 +21,17 @@
|
||||
--snapshot-cycle-sec=600
|
||||
|
||||
# create snapshot enabled on db exit
|
||||
--snapshot-on-db-exit=true
|
||||
--snapshot-on-exit=true
|
||||
|
||||
# max number of snapshots which will be kept on the disk at some point
|
||||
# if set to -1 the max number of snapshots is unlimited
|
||||
--max-retained-snapshots=1
|
||||
--snapshot-max-retained=1
|
||||
|
||||
# by default query engine runs in interpret mode
|
||||
--interpret=true
|
||||
|
||||
# database recovering is disabled by default
|
||||
--recover-on-startup=false
|
||||
--snapshot-recover-on-startup=false
|
||||
|
||||
# use ast caching
|
||||
--ast-cache=true
|
||||
|
@ -21,17 +21,17 @@
|
||||
--snapshot-cycle-sec=-1
|
||||
|
||||
# create snapshot disabled on db exit
|
||||
--snapshot-on-db-exit=true
|
||||
--snapshot-on-exit=true
|
||||
|
||||
# max number of snapshots which will be kept on the disk at some point
|
||||
# if set to -1 the max number of snapshots is unlimited
|
||||
--max-retained-snapshots=-1
|
||||
--snapshot-max-retained=-1
|
||||
|
||||
# by default query engine runs in interpret mode
|
||||
--interpret=true
|
||||
|
||||
# database recovering is disabled by default
|
||||
--recover-on-startup=false
|
||||
--snapshot-recover-on-startup=false
|
||||
|
||||
# use ast caching
|
||||
--ast-cache=true
|
||||
|
@ -68,9 +68,9 @@ parameters:
|
||||
--port | integer | 7687 | Communication port on which to listen.
|
||||
--num-workers | integer | CPU count[^1] | Number of Memgraph worker threads.
|
||||
--snapshot-cycle-sec | integer | 300 | Interval (seconds) between database snapshots.<br/>Value of -1 turns taking snapshots off.
|
||||
--max-retained-snapshots | integer | 3 | Number of retained snapshots.<br/>Value -1 means without limit.
|
||||
--snapshot-on-db-exit | bool | false | Make a snapshot when closing Memgraph.
|
||||
--recover-on-startup | bool | false | Recover the database on startup using the last<br/>stored snapshot.
|
||||
--snapshot-max-retained | integer | 3 | Number of retained snapshots.<br/>Value -1 means without limit.
|
||||
--snapshot-on-exit | bool | false | Make a snapshot when closing Memgraph.
|
||||
--snapshot-recover-on-startup | bool | false | Recover the database on startup using the last<br/>stored snapshot.
|
||||
--query-execution-time-sec | integer | 180 | Maximum allowed query execution time. <br/>Queries exceeding this limit will be aborted. Value of -1 means no limit.
|
||||
|
||||
[^1]: Maximum number of concurrent executions on the current CPU.
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
DEFINE_string(snapshot_directory, "snapshots",
|
||||
"Relative path to directory in which to save snapshots.");
|
||||
DEFINE_bool(recover_on_startup, false, "Recover database on startup.");
|
||||
DEFINE_bool(snapshot_recover_on_startup, false, "Recover database on startup.");
|
||||
|
||||
std::unique_ptr<GraphDbAccessor> Dbms::active() {
|
||||
return std::make_unique<GraphDbAccessor>(
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "utils/exceptions.hpp"
|
||||
|
||||
DECLARE_string(snapshot_directory);
|
||||
DECLARE_bool(recover_on_startup);
|
||||
DECLARE_bool(snapshot_recover_on_startup);
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
@ -45,7 +45,7 @@ class Dbms {
|
||||
throw utils::BasicException("Specified snapshot directory is a file!");
|
||||
}
|
||||
|
||||
if (FLAGS_recover_on_startup) {
|
||||
if (FLAGS_snapshot_recover_on_startup) {
|
||||
if (fs::exists(snapshot_root_dir)) {
|
||||
auto accessor = dbs.access();
|
||||
for (auto &snapshot_db_dir :
|
||||
|
@ -13,7 +13,7 @@
|
||||
DEFINE_int32(gc_cycle_sec, 30,
|
||||
"Amount of time between starts of two cleaning cycles in seconds. "
|
||||
"-1 to turn off.");
|
||||
DEFINE_int32(max_retained_snapshots, -1,
|
||||
DEFINE_int32(snapshot_max_retained, -1,
|
||||
"Number of retained snapshots, -1 means without limit.");
|
||||
DEFINE_int32(snapshot_cycle_sec, -1,
|
||||
"Amount of time between starts of two snapshooters in seconds. -1 "
|
||||
@ -22,7 +22,7 @@ DEFINE_int32(query_execution_time_sec, 180,
|
||||
"Maximum allowed query execution time. Queries exceeding this "
|
||||
"limit will be aborted. Value of -1 means no limit.");
|
||||
|
||||
DEFINE_bool(snapshot_on_db_exit, false, "Snapshot on exiting the database.");
|
||||
DEFINE_bool(snapshot_on_exit, false, "Snapshot on exiting the database.");
|
||||
|
||||
DECLARE_string(snapshot_directory);
|
||||
|
||||
@ -61,7 +61,7 @@ void GraphDb::StartSnapshooting() {
|
||||
GraphDbAccessor db_accessor(*this);
|
||||
snapshooter_.MakeSnapshot(db_accessor,
|
||||
fs::path(FLAGS_snapshot_directory) / name_,
|
||||
FLAGS_max_retained_snapshots);
|
||||
FLAGS_snapshot_max_retained);
|
||||
};
|
||||
snapshot_creator_.Run(std::chrono::seconds(FLAGS_snapshot_cycle_sec),
|
||||
create_snapshot);
|
||||
@ -134,12 +134,12 @@ GraphDb::~GraphDb() {
|
||||
transaction_killer_.Stop();
|
||||
|
||||
// Create last database snapshot
|
||||
if (FLAGS_snapshot_on_db_exit == true) {
|
||||
if (FLAGS_snapshot_on_exit == true) {
|
||||
GraphDbAccessor db_accessor(*this);
|
||||
LOG(INFO) << "Creating snapshot on shutdown..." << std::endl;
|
||||
const bool status = snapshooter_.MakeSnapshot(
|
||||
db_accessor, fs::path(FLAGS_snapshot_directory) / name_,
|
||||
FLAGS_max_retained_snapshots);
|
||||
FLAGS_snapshot_max_retained);
|
||||
if (status) {
|
||||
std::cout << "Snapshot created successfully." << std::endl;
|
||||
} else {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
bool Snapshooter::MakeSnapshot(GraphDbAccessor &db_accessor_,
|
||||
const fs::path &snapshot_folder,
|
||||
const int max_retained_snapshots) {
|
||||
const int snapshot_max_retained) {
|
||||
if (!fs::exists(snapshot_folder) &&
|
||||
!fs::create_directories(snapshot_folder)) {
|
||||
LOG(ERROR) << "Error while creating directory " << snapshot_folder;
|
||||
@ -20,7 +20,7 @@ bool Snapshooter::MakeSnapshot(GraphDbAccessor &db_accessor_,
|
||||
const auto snapshot_file = GetSnapshotFileName(snapshot_folder);
|
||||
if (fs::exists(snapshot_file)) return false;
|
||||
if (Encode(snapshot_file, db_accessor_)) {
|
||||
MaintainMaxRetainedFiles(snapshot_folder, max_retained_snapshots);
|
||||
MaintainMaxRetainedFiles(snapshot_folder, snapshot_max_retained);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -80,12 +80,12 @@ std::vector<fs::path> Snapshooter::GetSnapshotFiles(
|
||||
}
|
||||
|
||||
void Snapshooter::MaintainMaxRetainedFiles(const fs::path &snapshot_folder,
|
||||
int max_retained_snapshots) {
|
||||
if (max_retained_snapshots == -1) return;
|
||||
int snapshot_max_retained) {
|
||||
if (snapshot_max_retained == -1) return;
|
||||
std::vector<fs::path> files = GetSnapshotFiles(snapshot_folder);
|
||||
if (static_cast<int>(files.size()) <= max_retained_snapshots) return;
|
||||
if (static_cast<int>(files.size()) <= snapshot_max_retained) return;
|
||||
sort(files.begin(), files.end());
|
||||
for (int i = 0; i < static_cast<int>(files.size()) - max_retained_snapshots;
|
||||
for (int i = 0; i < static_cast<int>(files.size()) - snapshot_max_retained;
|
||||
++i) {
|
||||
if (!fs::remove(files[i])) {
|
||||
LOG(ERROR) << "Error while removing file: " << files[i];
|
||||
|
@ -21,12 +21,12 @@ class Snapshooter {
|
||||
* GraphDbAccessor used to access elements of GraphDb.
|
||||
* @param snapshot_folder:
|
||||
* folder where snapshots are stored.
|
||||
* @param max_retained_snapshots:
|
||||
* @param snapshot_max_retained:
|
||||
* maximum number of snapshots stored in snapshot folder.
|
||||
*/
|
||||
bool MakeSnapshot(GraphDbAccessor &db_accessor,
|
||||
const fs::path &snapshot_folder,
|
||||
int max_retained_snapshots);
|
||||
int snapshot_max_retained);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -21,17 +21,16 @@
|
||||
--snapshot-cycle-sec=-1
|
||||
|
||||
# create snapshot disabled on db exit
|
||||
--snapshot-on-db-exit=false
|
||||
--snapshot-on-exit=false
|
||||
|
||||
# max number of snapshots which will be kept on the disk at some point
|
||||
# if set to -1 the max number of snapshots is unlimited
|
||||
--max-retained-snapshots=-1
|
||||
--snapshot-max-retained=-1
|
||||
|
||||
# by default query engine runs in interpret mode
|
||||
--interpret=true
|
||||
|
||||
# database recovering is disabled by default
|
||||
--recover-on-startup=true
|
||||
--snapshot-recover-on-startup=true
|
||||
|
||||
# use ast caching
|
||||
--ast-cache=true
|
||||
|
@ -43,7 +43,7 @@ class DbmsRecoveryTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
void CreateSnapshot() {
|
||||
FLAGS_recover_on_startup = false;
|
||||
FLAGS_snapshot_recover_on_startup = false;
|
||||
Dbms dbms;
|
||||
auto dba = dbms.active();
|
||||
|
||||
@ -62,7 +62,7 @@ void CreateSnapshot() {
|
||||
}
|
||||
|
||||
void RecoverDbms() {
|
||||
FLAGS_recover_on_startup = true;
|
||||
FLAGS_snapshot_recover_on_startup = true;
|
||||
Dbms dbms;
|
||||
auto dba = dbms.active();
|
||||
|
||||
|
@ -44,7 +44,7 @@ class RecoveryTest : public ::testing::Test {
|
||||
CleanDbDir();
|
||||
FLAGS_snapshot_cycle_sec = -1;
|
||||
}
|
||||
const int max_retained_snapshots_ = 10;
|
||||
const int snapshot_max_retained_ = 10;
|
||||
};
|
||||
|
||||
void CreateSmallGraph(Dbms &dbms) {
|
||||
@ -78,11 +78,11 @@ void CreateBigGraph(Dbms &dbms) {
|
||||
dba->Commit();
|
||||
}
|
||||
|
||||
void TakeSnapshot(Dbms &dbms, int max_retained_snapshots_) {
|
||||
void TakeSnapshot(Dbms &dbms, int snapshot_max_retained_) {
|
||||
auto dba = dbms.active();
|
||||
Snapshooter snapshooter;
|
||||
snapshooter.MakeSnapshot(*dba.get(), SNAPSHOTS_RECOVERY_DEFAULT_DB_DIR,
|
||||
max_retained_snapshots_);
|
||||
snapshot_max_retained_);
|
||||
}
|
||||
|
||||
std::string GetLatestSnapshot() {
|
||||
@ -100,7 +100,7 @@ TEST_F(RecoveryTest, TestEncoding) {
|
||||
// reading graph is tested.
|
||||
Dbms dbms;
|
||||
CreateSmallGraph(dbms);
|
||||
TakeSnapshot(dbms, max_retained_snapshots_);
|
||||
TakeSnapshot(dbms, snapshot_max_retained_);
|
||||
std::string snapshot = GetLatestSnapshot();
|
||||
|
||||
FileReaderBuffer buffer;
|
||||
@ -150,7 +150,7 @@ TEST_F(RecoveryTest, TestEncodingAndDecoding) {
|
||||
// the snapshot file. After creation graph is tested.
|
||||
Dbms dbms;
|
||||
CreateSmallGraph(dbms);
|
||||
TakeSnapshot(dbms, max_retained_snapshots_);
|
||||
TakeSnapshot(dbms, snapshot_max_retained_);
|
||||
std::string snapshot = GetLatestSnapshot();
|
||||
|
||||
// New dbms is needed - old dbms has database "default"
|
||||
@ -193,7 +193,7 @@ TEST_F(RecoveryTest, TestEncodingAndRecovering) {
|
||||
// the snapshot file. After creation graph is tested.
|
||||
Dbms dbms;
|
||||
CreateBigGraph(dbms);
|
||||
TakeSnapshot(dbms, max_retained_snapshots_);
|
||||
TakeSnapshot(dbms, snapshot_max_retained_);
|
||||
std::string snapshot = GetLatestSnapshot();
|
||||
|
||||
// New dbms is needed - old dbms has database "default"
|
||||
@ -236,7 +236,7 @@ TEST_F(RecoveryTest, TestLabelPropertyIndexRecovery) {
|
||||
dba->BuildIndex(dba->Label("label"), dba->Property("prop"));
|
||||
dba->Commit();
|
||||
CreateBigGraph(dbms);
|
||||
TakeSnapshot(dbms, max_retained_snapshots_);
|
||||
TakeSnapshot(dbms, snapshot_max_retained_);
|
||||
std::string snapshot = GetLatestSnapshot();
|
||||
|
||||
Dbms dbms_recover;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "database/dbms.hpp"
|
||||
#include "durability/snapshooter.hpp"
|
||||
|
||||
DECLARE_bool(snapshot_on_db_exit);
|
||||
DECLARE_bool(snapshot_on_exit);
|
||||
DECLARE_int32(snapshot_cycle_sec);
|
||||
DECLARE_string(snapshot_directory);
|
||||
|
||||
@ -47,14 +47,14 @@ class SnapshotTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(SnapshotTest, CreateLessThanMaxRetainedSnapshotsTests) {
|
||||
const int max_retained_snapshots = 10;
|
||||
const int snapshot_max_retained = 10;
|
||||
Dbms dbms;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
auto dba = dbms.active();
|
||||
Snapshooter snapshooter;
|
||||
snapshooter.MakeSnapshot(*dba.get(), SNAPSHOTS_TEST_DEFAULT_DB_DIR,
|
||||
max_retained_snapshots);
|
||||
snapshot_max_retained);
|
||||
}
|
||||
|
||||
std::vector<fs::path> files = GetFilesFromDir(SNAPSHOTS_TEST_DEFAULT_DB_DIR);
|
||||
@ -62,7 +62,7 @@ TEST_F(SnapshotTest, CreateLessThanMaxRetainedSnapshotsTests) {
|
||||
}
|
||||
|
||||
TEST_F(SnapshotTest, CreateMoreThanMaxRetainedSnapshotsTests) {
|
||||
const int max_retained_snapshots = 2;
|
||||
const int snapshot_max_retained = 2;
|
||||
Dbms dbms;
|
||||
|
||||
fs::path first_snapshot;
|
||||
@ -70,7 +70,7 @@ TEST_F(SnapshotTest, CreateMoreThanMaxRetainedSnapshotsTests) {
|
||||
auto dba = dbms.active();
|
||||
Snapshooter snapshooter;
|
||||
snapshooter.MakeSnapshot(*dba.get(), SNAPSHOTS_TEST_DEFAULT_DB_DIR,
|
||||
max_retained_snapshots);
|
||||
snapshot_max_retained);
|
||||
if (i == 0) {
|
||||
std::vector<fs::path> files_begin =
|
||||
GetFilesFromDir(SNAPSHOTS_TEST_DEFAULT_DB_DIR);
|
||||
@ -86,14 +86,14 @@ TEST_F(SnapshotTest, CreateMoreThanMaxRetainedSnapshotsTests) {
|
||||
}
|
||||
|
||||
TEST_F(SnapshotTest, CreateSnapshotWithUnlimitedMaxRetainedSnapshots) {
|
||||
const int max_retained_snapshots = -1;
|
||||
const int snapshot_max_retained = -1;
|
||||
Dbms dbms;
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
auto dba = dbms.active();
|
||||
Snapshooter snapshooter;
|
||||
snapshooter.MakeSnapshot(*dba.get(), SNAPSHOTS_TEST_DEFAULT_DB_DIR,
|
||||
max_retained_snapshots);
|
||||
snapshot_max_retained);
|
||||
}
|
||||
|
||||
std::vector<fs::path> files = GetFilesFromDir(SNAPSHOTS_TEST_DEFAULT_DB_DIR);
|
||||
@ -103,7 +103,7 @@ TEST_F(SnapshotTest, CreateSnapshotWithUnlimitedMaxRetainedSnapshots) {
|
||||
TEST_F(SnapshotTest, TestSnapshotFileOnDbDestruct) {
|
||||
{
|
||||
FLAGS_snapshot_directory = SNAPSHOTS_FOLDER_ALL_DB;
|
||||
FLAGS_snapshot_on_db_exit = true;
|
||||
FLAGS_snapshot_on_exit = true;
|
||||
Dbms dbms;
|
||||
auto dba = dbms.active();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user