Skip to content

Commit

Permalink
Fixed persistence config
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhichang committed Jul 17, 2024
1 parent 0bc7095 commit bddc525
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 5 deletions.
2 changes: 2 additions & 0 deletions conf/infinity_conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ wal_flush = "only_write"

[resource]
resource_dir = "/var/infinity/resource"

[persistence]
26 changes: 26 additions & 0 deletions src/main/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,16 @@ Status Config::Init(const SharedPtr<String> &config_path, DefaultConfig* default
UnrecoverableError(status.message());
}

// Persistence Dir
String persistence_dir = DEFAULT_PERSISTENCE_DIR.data();
UniquePtr<StringOption> persistence_dir_option = MakeUnique<StringOption>(PERSISTENCE_DIR_OPTION_NAME, persistence_dir);
global_options_.AddOption(std::move(persistence_dir_option));

// Persistence Object Size Limit
i64 persistence_object_size_limit = DEFAULT_PERSISTENCE_OBJECT_SIZE_LIMIT;
UniquePtr<IntegerOption> persistence_object_size_limit_option =
MakeUnique<IntegerOption>(PERSISTENCE_OBJECT_SIZE_LIMIT_OPTION_NAME, persistence_object_size_limit, std::numeric_limits<i64>::max(), 0);
global_options_.AddOption(std::move(persistence_object_size_limit_option));
} else {
config_toml = toml::parse_file(*config_path);

Expand Down Expand Up @@ -1236,6 +1246,22 @@ Status Config::Init(const SharedPtr<String> &config_path, DefaultConfig* default
}
}
}
if (global_options_.GetOptionByIndex(GlobalOptionIndex::kPersistenceDir) == nullptr) {
String persistence_dir = DEFAULT_PERSISTENCE_DIR.data();
UniquePtr<StringOption> persistence_dir_option = MakeUnique<StringOption>(PERSISTENCE_DIR_OPTION_NAME, persistence_dir);
global_options_.AddOption(std::move(persistence_dir_option));
}
if (global_options_.GetOptionByIndex(GlobalOptionIndex::kPersistenceObjectSizeLimit) == nullptr) {
i64 persistence_object_size_limit = DEFAULT_PERSISTENCE_OBJECT_SIZE_LIMIT;
UniquePtr<IntegerOption> persistence_object_size_limit_option =
MakeUnique<IntegerOption>(PERSISTENCE_OBJECT_SIZE_LIMIT_OPTION_NAME,
persistence_object_size_limit,
std::numeric_limits<i64>::max(),
0);
global_options_.AddOption(std::move(persistence_object_size_limit_option));
}
} else {
return Status::InvalidConfig("No 'persistence' section in configure file.");
}
}

Expand Down
2 changes: 2 additions & 0 deletions test/data/config/infinity_conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ wal_dir = "/var/infinity/wal"

[resource]
resource_dir = "/var/infinity/resource"

[persistence]
4 changes: 3 additions & 1 deletion test/data/config/test_buffer_obj.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ delta_checkpoint_interval = "1s"
buffer_manager_size = "512kb"
temp_dir = "/var/infinity/tmp"

[resource]
[resource]

[persistence]
4 changes: 3 additions & 1 deletion test/data/config/test_buffer_obj_2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ full_checkpoint_interval = "1s"
buffer_manager_size = "32mb"
temp_dir = "/var/infinity/tmp"

[resource]
[resource]

[persistence]
1 change: 1 addition & 0 deletions test/data/config/test_catalog_delta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ delta_checkpoint_interval = "1s"

[buffer]
[resource]
[persistence]
1 change: 1 addition & 0 deletions test/data/config/test_checkpoint.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ delta_checkpoint_interval = "5s"

[buffer]
[resource]
[persistence]
3 changes: 2 additions & 1 deletion test/data/config/test_cleanup_task.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ compact_interval = "0s"
full_checkpoint_interval = "0s"
#short checkpoint interval to allow quick cleanup
delta_checkpoint_interval = "1s"
[resource]
[resource]
[persistence]
3 changes: 2 additions & 1 deletion test/data/config/test_cleanup_task_silent.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ compact_interval = "0s"
full_checkpoint_interval = "0s"
#short checkpoint interval to allow quick cleanup
delta_checkpoint_interval = "1s"
[resource]
[resource]
[persistence]
4 changes: 3 additions & 1 deletion test/data/config/test_close_all_bgtask.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ delta_checkpoint_interval = "0s"
# close full checkpoint
full_checkpoint_interval = "0s"

[resource]
[resource]

[persistence]
1 change: 1 addition & 0 deletions test/data/config/test_close_ckp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ wal_compact_threshold = "10KB"
[storage]
[buffer]
[resource]
[persistence]
1 change: 1 addition & 0 deletions test/data/config/test_optimize.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ compact_interval = "0s"
[wal]
[buffer]
[resource]
[persistence]

0 comments on commit bddc525

Please sign in to comment.