Persisting hpfs log responses to the hpfs (#291)

Fixing the in memory raw shard hash update.
Passing the seq_no of index update to verify that the index records are consistent.
Restart rw session after completing last primary shard sync.
Fixed issue in fs read write by multiple threads.
Hpfs log sync modifications.
This commit is contained in:
Chalith Desaman
2021-04-16 20:06:20 +05:30
committed by GitHub
parent 2283d2bf89
commit 05e8077e5b
14 changed files with 157 additions and 114 deletions

View File

@@ -36,8 +36,6 @@ namespace ledger
ledger::ledger_sync ledger_sync_worker; // Global ledger file system sync instance.
ledger::ledger_serve ledger_server; // Ledger file server instance.
std::shared_mutex primary_index_file_mutex;
constexpr uint32_t LEDGER_FS_ID = 1;
constexpr int FILE_PERMS = 0644;
@@ -160,7 +158,7 @@ namespace ledger
ctx.set_last_primary_shard_id(p2p::sequence_hash{shard_seq_no, last_primary_shard_hash});
// Update the hpfs log index file only in full history mode.
if (conf::cfg.node.history == conf::HISTORY::FULL && sc::contract_fs.update_hpfs_log_index() == -1)
if (conf::cfg.node.history == conf::HISTORY::FULL && sc::contract_fs.update_hpfs_log_index(new_lcl_id.seq_no) == -1)
{
LOG_ERROR << errno << ": Error updating the hpfs log index file.";
return -1;
@@ -193,6 +191,11 @@ namespace ledger
{
sqlite::close_db(&db);
// Update in-memory context raw shard hash after inserting new record.
util::h32 last_raw_shard_hash;
if (ledger_fs.get_hash(last_raw_shard_hash, hpfs::RW_SESSION_NAME, std::string(RAW_DIR).append("/").append(std::to_string(shard_seq_no))) != -1)
ctx.set_last_raw_shard_id(p2p::sequence_hash{shard_seq_no, last_raw_shard_hash});
// Remove old shards if new one got created.
if (shard_res == 1)
remove_old_shards(lcl_id.seq_no, RAW_SHARD_SIZE, conf::cfg.node.history_config.max_raw_shards, RAW_DIR);