add spin_yield to undo DB, increase undo DB size, trace all objects ID, check double close DB
This commit is contained in:
parent
d7c654500e
commit
aa988d3fdc
7 changed files with 38 additions and 7 deletions
|
|
@ -56,6 +56,8 @@ if (BUILD_PEERPLAYS_TESTNET)
|
|||
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis-testnet.json" CACHE PATH "location of the genesis.json to embed in the executable" )
|
||||
#add_compile_definitions(BUILD_PEERPLAYS_TESTNET=1)
|
||||
add_definitions(-DBUILD_PEERPLAYS_TESTNET=1)
|
||||
add_definitions(-DBOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING=1)
|
||||
add_definitions(-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE=1)
|
||||
message ("\n====================\nBuilding for Testnet\n====================\n")
|
||||
else (BUILD_PEERPLAYS_TESTNET)
|
||||
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis-mainnet.json" CACHE PATH "location of the genesis.json to embed in the executable" )
|
||||
|
|
|
|||
|
|
@ -853,9 +853,10 @@ application::~application() {
|
|||
my->_p2p_network->close();
|
||||
my->_p2p_network.reset();
|
||||
}
|
||||
if (my->_chain_db) {
|
||||
my->_chain_db->close();
|
||||
}
|
||||
//if (my->_chain_db) {
|
||||
// my->_chain_db->close();
|
||||
// my->_chain_db.reset();
|
||||
//}
|
||||
}
|
||||
|
||||
void application::set_program_options(boost::program_options::options_description &cli,
|
||||
|
|
@ -1010,8 +1011,10 @@ void application::shutdown_plugins() {
|
|||
void application::shutdown() {
|
||||
if (my->_p2p_network)
|
||||
my->_p2p_network->close();
|
||||
if (my->_chain_db)
|
||||
if (my->_chain_db){
|
||||
my->_chain_db->close();
|
||||
my->_chain_db.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void application::initialize_plugins(const boost::program_options::variables_map &options) {
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ void database::initialize_evaluators()
|
|||
void database::initialize_indexes()
|
||||
{
|
||||
reset_indexes();
|
||||
_undo_db.set_max_size( GRAPHENE_MIN_UNDO_HISTORY );
|
||||
_undo_db.set_max_size( 100 /*GRAPHENE_MIN_UNDO_HISTORY*/ );
|
||||
|
||||
//Protocol object indexes
|
||||
add_index< primary_index<asset_index, 13> >(); // 8192 assets per chunk
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ namespace graphene { namespace db {
|
|||
const object& get( object_id_type id )const
|
||||
{
|
||||
auto maybe_found = find( id );
|
||||
ilog("get ID is ${id}", ("id", id));
|
||||
FC_ASSERT( maybe_found != nullptr, "Unable to find Object", ("id",id) );
|
||||
return *maybe_found;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@
|
|||
#include <graphene/db/object.hpp>
|
||||
#include <deque>
|
||||
#include <fc/exception/exception.hpp>
|
||||
#include <fc/thread/spin_yield_lock.hpp>
|
||||
#include <fc/fwd.hpp>
|
||||
#include <fc/thread/unique_lock.hpp>
|
||||
|
||||
namespace graphene { namespace db {
|
||||
|
||||
|
|
@ -132,6 +135,8 @@ namespace graphene { namespace db {
|
|||
std::deque<undo_state> _stack;
|
||||
object_database& _db;
|
||||
size_t _max_size = 256;
|
||||
|
||||
mutable fc::spin_yield_lock _spin_yield;
|
||||
};
|
||||
|
||||
} } // graphene::db
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include <graphene/db/undo_database.hpp>
|
||||
#include <fc/reflect/variant.hpp>
|
||||
|
||||
#include <fc/thread/spin_yield_lock.hpp>
|
||||
|
||||
namespace graphene { namespace db {
|
||||
|
||||
void undo_database::enable() { _disabled = false; }
|
||||
|
|
@ -44,6 +46,8 @@ undo_database::session::~session() {
|
|||
|
||||
undo_database::session undo_database::start_undo_session( bool force_enable )
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
if( _disabled && !force_enable ) return session(*this);
|
||||
bool disable_on_exit = _disabled && force_enable;
|
||||
if( force_enable )
|
||||
|
|
@ -58,6 +62,8 @@ undo_database::session undo_database::start_undo_session( bool force_enable )
|
|||
}
|
||||
void undo_database::on_create( const object& obj )
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
if( _disabled ) return;
|
||||
|
||||
if( _stack.empty() )
|
||||
|
|
@ -73,6 +79,8 @@ void undo_database::on_modify( const object& obj )
|
|||
{
|
||||
if( _disabled ) return;
|
||||
|
||||
synchronized(_spin_yield)
|
||||
|
||||
if( _stack.empty() )
|
||||
_stack.emplace_back();
|
||||
auto& state = _stack.back();
|
||||
|
|
@ -86,6 +94,8 @@ void undo_database::on_remove( const object& obj )
|
|||
{
|
||||
if( _disabled ) return;
|
||||
|
||||
synchronized(_spin_yield)
|
||||
|
||||
if( _stack.empty() )
|
||||
_stack.emplace_back();
|
||||
undo_state& state = _stack.back();
|
||||
|
|
@ -105,7 +115,9 @@ void undo_database::on_remove( const object& obj )
|
|||
}
|
||||
|
||||
void undo_database::undo()
|
||||
{ try {
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
try {
|
||||
FC_ASSERT( !_disabled );
|
||||
FC_ASSERT( _active_sessions > 0 );
|
||||
disable();
|
||||
|
|
@ -136,6 +148,8 @@ void undo_database::undo()
|
|||
|
||||
void undo_database::merge()
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
FC_ASSERT( _active_sessions > 0 );
|
||||
if( _active_sessions == 1 && _stack.size() == 1 )
|
||||
{
|
||||
|
|
@ -256,12 +270,16 @@ void undo_database::merge()
|
|||
}
|
||||
void undo_database::commit()
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
FC_ASSERT( _active_sessions > 0 );
|
||||
--_active_sessions;
|
||||
}
|
||||
|
||||
void undo_database::pop_commit()
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
FC_ASSERT( _active_sessions == 0 );
|
||||
FC_ASSERT( !_stack.empty() );
|
||||
|
||||
|
|
@ -299,6 +317,8 @@ void undo_database::pop_commit()
|
|||
}
|
||||
const undo_state& undo_database::head()const
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
FC_ASSERT( !_stack.empty() );
|
||||
return _stack.back();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 6171e973c7fcfc9e0a39eaee2f05da84416a90e6
|
||||
Subproject commit 711b04fb4f21bcaf8fdf00f51f4d6410849bec92
|
||||
Loading…
Reference in a new issue