cculianu / Fulcrum

A fast & nimble SPV Server for BCH, BTC, and LTC
Other
331 stars 76 forks source link

Finish Debugging #159

Open santochibtc opened 1 year ago

santochibtc commented 1 year ago

How do you finish a debugging session without breaking the database?

cculianu commented 1 year ago

What do you mean?

santochibtc commented 1 year ago

I don't know how to stop the debugging, how do I send the signal to Fulcrum to stop safely? Can I just put a breakpoint and stop the debugging when the program hits the breakpoint?

cculianu commented 1 year ago

So long as the breakpoint is not in the Storage.cpp Storage::addBlock function, then yes. It should be fine to just kill it.
(Disk files can only get corrupted inside that call stack where it's adding a block.)

However just to be sure -- in case rocksdb does funny business under a debugger -- I would however instead send signal SIGINT to the process and let it shut down normally just to be safe.

santochibtc commented 1 year ago

Yesterday I disabled the network connection before killing the process to be sure that it wasn't writing and now it does not start "FATAL: Caught exception: It appears that Fulcrum was forcefully killed in the middle of committing a block to the db"

cculianu commented 1 year ago

Hmm. Well.. did you stop the process while it was in Storage::addBlock?

santochibtc commented 1 year ago

I don't know, I stopped the debugging without setting a breakpoint. I assumed that after some seconds without connection the process won't be writing

cculianu commented 1 year ago

Well if the process is frozen due to debug.. who knows where it was and what it as doing. Sorry you lost your datadir :/

I will fix that issue at some point. I just need to write a bunch of code to backtrack in that case and figure out what is corrupted and I just haven't done that.

santochibtc commented 1 year ago

I want to debug the crash. I have built rocksdb and replaced the library and the headers at fulcrum\staticlibs\rocksdb. I am getting this errors compiling fulcrum: fulcrum\src\Storage.cpp:2096: error: invalid use of incomplete type 'using element_type = class rocksdb::Cache' {aka 'class rocksdb::Cache'} fulcrum\src\Storage.cpp: In member function 'virtual StatsMixin::Stats Storage::stats() const': fulcrum\src\Storage.cpp:2096:45: error: invalid use of incomplete type 'using element_type = class rocksdb::Cache' {aka 'class rocksdb::Cache'} cmap["usage"] = qulonglong(cache->GetUsage());

fulcrum\src\Storage.cpp:2097: error: invalid use of incomplete type 'using element_type = class rocksdb::Cache' {aka 'class rocksdb::Cache'} cmap["capacity"] = qulonglong(cache->GetCapacity());

fulcrum\src\Storage.cpp:36: In file included from fulcrum\src\Storage.cpp:36: fulcrum\staticlibs\rocksdb\include/rocksdb/cache.h:24:7: note: forward declaration of 'using element_type = class rocksdb::Cache' {aka 'class rocksdb::Cache'} class Cache; // defined in advanced_cache.h

santochibtc commented 1 year ago

Fix it adding #include <rocksdb/advanced_cache.h> to Storage.cpp. Is this correct?