Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to save unclean object database to file during replay #946

Closed
2 of 8 tasks
abitmore opened this issue May 22, 2018 · 16 comments
Closed
2 of 8 tasks

Possible to save unclean object database to file during replay #946

abitmore opened this issue May 22, 2018 · 16 comments
Labels
1b User Story The User Story details a requirement. It may reference a parent Epic. It may reference child Task(s) 2d Developing Status indicating currently designing and developing a solution 3d Bug Classification indicating the existing implementation does not match the intention of the design 6 Security Impact flag identifying system/user security bug

Comments

@abitmore
Copy link
Member

abitmore commented May 22, 2018

During replay, undo_db is disabled, that said, when there is an exception thrown, changes made to object database won't rewound, which means the in-memory object database would be unclean.

When caught the exception, the node will dump object database from memory to disk. That means the on-disk object database would be unclean.

On next (and future) startup, if does not specify --replay-blockchain, the on-disk object database would be considered clean and be loaded into memory directly.

Related code:

} catch( const fc::exception& e ) {
// deleting the node can yield, so do this outside the exception handler
unhandled_exception = e;
}
if (unhandled_exception)
{
elog("Exiting with error:\n${e}", ("e", unhandled_exception->to_detail_string()));
node->shutdown();
delete node;
return 1;
}
}

void application::shutdown()
{
if( my->_p2p_network )
my->_p2p_network->close();
if( my->_chain_db )
{
my->_chain_db->close();

CORE TEAM TASK LIST

  • Evaluate / Prioritize Feature Request
  • Refine User Stories / Requirements
  • Define Test Cases
  • Design / Develop Solution
  • Perform QA/Testing
  • Update Documentation
@abitmore abitmore added the bug label May 22, 2018
@abitmore abitmore added this to the 201807 - Next Non-Consensus-Changing Release milestone May 22, 2018
@pmconrad
Copy link
Contributor

Nice catch.

@ryanRfox ryanRfox added 1b User Story The User Story details a requirement. It may reference a parent Epic. It may reference child Task(s) 2b Gathering Requirements Status indicating currently refining User Stories and defining Requirements 3d Bug Classification indicating the existing implementation does not match the intention of the design 6 Security Impact flag identifying system/user security labels May 23, 2018
@cogutvalera
Copy link
Member

@ryanRfox I want to claim this issue if possible please

@ryanRfox
Copy link
Contributor

ryanRfox commented Sep 4, 2018

Yes, @cogutvalera I will assign you. Please provide an estimate and the Core Team will review it.

@ryanRfox
Copy link
Contributor

ryanRfox commented Sep 4, 2018

@abitmore I added this to 201810 Feature Release because it is labeled a bug and wanted some additional visibility of its progress. If it's not complete by release time, we can move it back to Future Non-Consensus (please leave it in Community Claims)

@ryanRfox ryanRfox added 2d Developing Status indicating currently designing and developing a solution and removed 2b Gathering Requirements Status indicating currently refining User Stories and defining Requirements labels Sep 4, 2018
@cogutvalera
Copy link
Member

@ryanRfox my estimation for this issue is approximately about 2 hours

@abitmore
Copy link
Member Author

abitmore commented Sep 8, 2018

@cogutvalera I'm surprised. I didn't think it can be done in 2 hours. Please describe how to fix, and analyse pros and cons.

@cogutvalera
Copy link
Member

@abitmore maybe I'm wrong with my estimation, very wrong, please help me to estimate this issue more correctly enough if you can.

My thoughts were that we can use something like next snippet of code after this line here https://github.com/bitshares/bitshares-core/blob/develop/programs/witness_node/main.cpp#L157

if (fc::exists(data_dir))
         fc::create_directories( data_dir / "object_database" / "lock" );

and here in the start of flush method we can use something like next code
https://github.com/bitshares/bitshares-core/blob/develop/libraries/db/object_database.cpp#L71

if( fc::exists( _data_dir / "object_database" / "lock" ) ) {
      fc::remove_all( _data_dir / "object_database" / "lock" );
      return;
   }

Are my thoughts wrong ? Or is it a good direction or not so ?

Thank you very much !

@cogutvalera
Copy link
Member

My idea is simple but maybe I am completely wrong with it. Still researching different possibilities. My idea: not to flush object database in event of exception, also need to add check if it was in reply mode or not, but I hope you understand my idea correctly.

Thanks !

@abitmore
Copy link
Member Author

abitmore commented Sep 8, 2018

Thanks. Perhaps it's not as hard as I thought. I think we need to add a parameter to shutdown() function to tell the object database whether the state is clean, to decide whether to dump it to disk.

@cogutvalera
Copy link
Member

Wow, you are absolutely right about parameter in shutdown ! Did not thought yet about it. Nice idea ! Thanks a lot !

@cogutvalera
Copy link
Member

At the beginning I thought the same as @abitmore that this issue is much harder but later after some researches I was surprised too that it is much easier than I have been expected.

@ryanRfox
Copy link
Contributor

@cogutvalera and @abitmore did you two come to consensus about the estimate (2 hours)? I've assigned to @cogutvalera now and leave the estimate as TBD until I hear from you both. Thanks

@abitmore
Copy link
Member Author

@ryanRfox depends on what's done. IMHO 2 hours is not sufficient.

@cogutvalera
Copy link
Member

@ryanRfox I'm absolutely agree with @abitmore

@cogutvalera
Copy link
Member

guys check please PR #1311

@pmconrad
Copy link
Contributor

Tried to reproduce but failed.
Apparently fixed by 7c3968b in #1529 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1b User Story The User Story details a requirement. It may reference a parent Epic. It may reference child Task(s) 2d Developing Status indicating currently designing and developing a solution 3d Bug Classification indicating the existing implementation does not match the intention of the design 6 Security Impact flag identifying system/user security bug
Projects
None yet
Development

No branches or pull requests

5 participants