Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
hive
hive
Commits
c001f06e
Commit
c001f06e
authored
Aug 13, 2020
by
Bartek Wrona
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented loading plugin external data from snapshot.
parent
30f15173
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
5 deletions
+45
-5
libraries/plugins/account_history_rocksdb/account_history_rocksdb_plugin.cpp
...ccount_history_rocksdb/account_history_rocksdb_plugin.cpp
+45
-5
No files found.
libraries/plugins/account_history_rocksdb/account_history_rocksdb_plugin.cpp
View file @
c001f06e
...
...
@@ -604,6 +604,7 @@ public:
chain
::
util
::
disconnect_signal
(
_on_irreversible_block_conn
);
flushStorage
();
cleanupColumnHandles
();
_storage
->
Close
();
_storage
.
reset
();
}
...
...
@@ -621,9 +622,20 @@ private:
bool
createDbSchema
(
const
bfs
::
path
&
path
);
void
cleanupColumnHandles
()
{
cleanupColumnHandles
(
_storage
.
get
());
}
void
cleanupColumnHandles
(
::
rocksdb
::
DB
*
db
)
{
for
(
auto
*
h
:
_columnHandles
)
delete
h
;
{
auto
s
=
db
->
DestroyColumnFamilyHandle
(
h
);
if
(
s
.
ok
()
==
false
)
{
elog
(
"Cannot destroy column family handle. Error: `${e}'"
,
(
"e"
,
s
.
ToString
()));
}
}
_columnHandles
.
clear
();
}
...
...
@@ -1208,7 +1220,7 @@ void account_history_rocksdb_plugin::impl::supplement_snapshot(const hive::chain
backupEngine
.
reset
(
_backupEngine
);
ilog
(
"Attempting to create a AccountHistoryRocksDB backup in the location: `${p}'"
,
(
"p"
,
pathString
));
ilog
(
"Attempting to create a
n
AccountHistoryRocksDB backup in the location: `${p}'"
,
(
"p"
,
pathString
));
std
::
string
meta_data
=
"Account History RocksDB plugin data. Current head block: "
;
meta_data
+=
std
::
to_string
(
_mainDb
.
head_block_num
());
...
...
@@ -1233,9 +1245,37 @@ void account_history_rocksdb_plugin::impl::load_additional_data_from_snapshot(co
return
;
}
ilog
(
"Attempting to load external data for Account History RocksDB plugin from location: `${p}'"
,
(
"p"
,
extdata_path
.
string
()));
auto
pathString
=
extdata_path
.
to_native_ansi_path
();
ilog
(
"Attempting to load external data for Account History RocksDB plugin from location: `${p}'"
,
(
"p"
,
pathString
));
::
rocksdb
::
Env
*
backupEnv
=
::
rocksdb
::
Env
::
Default
();
::
rocksdb
::
BackupableDBOptions
backupableDbOptions
(
pathString
);
std
::
unique_ptr
<::
rocksdb
::
BackupEngineReadOnly
>
backupEngine
;
::
rocksdb
::
BackupEngineReadOnly
*
_backupEngine
=
nullptr
;
auto
status
=
::
rocksdb
::
BackupEngineReadOnly
::
Open
(
backupEnv
,
backupableDbOptions
,
&
_backupEngine
);
checkStatus
(
status
);
backupEngine
.
reset
(
_backupEngine
);
ilog
(
"Attempting to restore an AccountHistoryRocksDB backup from the backup location: `${p}'"
,
(
"p"
,
pathString
));
shutdownDb
();
ilog
(
"Attempting to destroy current AHR storage..."
);
::
rocksdb
::
Options
destroyOpts
;
::
rocksdb
::
DestroyDB
(
_storagePath
.
string
(),
destroyOpts
);
bfs
::
path
walDir
(
_storagePath
);
walDir
/=
"WAL"
;
status
=
backupEngine
->
RestoreDBFromLatestBackup
(
_storagePath
.
string
(),
walDir
.
string
());
checkStatus
(
status
);
ilog
(
"Restoring AccountHistoryRocksDB backup from the location: `${p}' finished"
,
(
"p"
,
pathString
));
openDb
();
}
uint32_t
account_history_rocksdb_plugin
::
impl
::
get_lib
(
const
uint32_t
*
fallbackIrreversibleBlock
/*= nullptr*/
)
const
...
...
@@ -1308,7 +1348,7 @@ bool account_history_rocksdb_plugin::impl::createDbSchema(const bfs::path& path)
if
(
s
.
ok
())
{
cleanupColumnHandles
();
cleanupColumnHandles
(
db
);
delete
db
;
return
false
;
/// DB does not need data import.
}
...
...
@@ -1326,7 +1366,7 @@ bool account_history_rocksdb_plugin::impl::createDbSchema(const bfs::path& path)
saveStoreVersion
();
/// Store initial values of Seq-IDs for held objects.
flushWriteBuffer
(
db
);
cleanupColumnHandles
();
cleanupColumnHandles
(
db
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment