Skip to content

Conversation

@dooglus
Copy link
Contributor

@dooglus dooglus commented Mar 28, 2012

When set, -dbtrimlogs will delete old unused database log files every 5000 blocks. Otherwise several GB of logs build up while downloading the (1GB) blockchain, and are only deleted when the client exits.

Fixes part of the bug #999. The QT client still sometimes crashes when it runs out of disk space.

@sipa
Copy link
Member

sipa commented Mar 28, 2012

Have you tested that this actually works? I've been playing for a few hours now with DB_LOG_REMOVE, DB_LOG_AUTO_REMOVE, closing all db files occasionally, checkpoinging, flushing, stopping and restarting DbEnv, ... but all I've seen are a lot of unexplainable segfauls, and not a single deleted logfile.

EDIT: apparently it does. I'm baffled.

@gavinandresen
Copy link
Contributor

Nice! I'm baffled, too.

I don't think this should be a command-line option, though: I think it should just happen, I can't think of any reason to keep gigabytes of logs around.

@dooglus
Copy link
Contributor Author

dooglus commented Mar 28, 2012

@sipa: I tested it a lot before making the pull request, yes. It seems to work well in db5.1.25. I don't have db4.x.

@gavinandresen: I think the logs are so you can do database recovery in the event of a crash.

It seems that in the event of a crash we usually manage to clean up the logs before exiting however :)

I'll update my patch so it's not a command line option.

@sipa
Copy link
Member

sipa commented Mar 28, 2012

I'm testing a bit more extensive patch that counts the number of transactions updated or time since last flush as condition for flushing (instead of 5000 blocks), plus a few other changes. I'm benchmarking now.

Thanks for showing this was possible at all - I had almost given up (seems there was a bug in my load-blocks-from-file patch that didn't call txn_checkpoint at all, which prevented log cleaning).

@dooglus
Copy link
Contributor Author

dooglus commented Mar 29, 2012

No problem. I don't care what triggers the deletion so long as it's done occasionally.

To arrange for rapid blockchain downloading to test this I've been using a second computer on the same LAN with a complete copy of the blockchain and connecting only to it.

@sipa
Copy link
Member

sipa commented Mar 29, 2012

Ok, one full load of the blockchain up to 172000 (from a local file) completed in 35 minutes. That's a few minutes slower than a previous benchmark, but it never needed more than 12 log files (of 10 MiB again). This did a log flush every 200k transactions (which was every 0.5-2 minutes). I'll post the code tomorrow.

@dooglus
Copy link
Contributor Author

dooglus commented Mar 29, 2012

How much of that was spent loading the blocks 168000 to 172000? The last checkpoint being at 168k makes the last 4k blocks so much slower to load.

How about adding a new checkpoint before the release of 0.6.0?

@gavinandresen
Copy link
Contributor

grrr...

So after WASTING time testing dbenv.set_flags(DB_LOG_AUTO_REMOVE, 1) this afternoon, I discover the correct call is actually log_set_config:

dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);

Testing with a 10MB logfile size and the logs are automatically being cleaned up as the blockchain is downloading.

(the set_flags call didn't trigger an error or warning because LOG_AUTO_REMOVE and AUTO_COMMIT share the same #define)

@sipa
Copy link
Member

sipa commented Mar 29, 2012

So there are three options now: a) remove logs at given points b) flush + remove logs at given points c) use auto remove.

I wonder if there is any danger in using auto remove (meaning logs will be removed while transactions/databases are open). I suppose not.

Gavin, how many log files were present at most at one given time during the block chain download?

@gavinandresen
Copy link
Contributor

The most log files present at one given time with LOG_AUTO_REMOVE and 10M logfiles was 5.

Typical is 2.

Raw data (ls -l in the database/ dir run every 2 minutes): https://gist.github.com/2236954

@gavinandresen
Copy link
Contributor

Thanks for the help Chris-- without this pull I think we would have given up hope of finding a good solution. But I'm going to close, because using AUTO_REMOVE (properly) is fewer lines of code.

suprnurd pushed a commit to chaincoin-legacy/chaincoin that referenced this pull request Dec 5, 2017
…phrase (which locks wallet back after specified timeout) (bitcoin#1004)
ptschip pushed a commit to ptschip/bitcoin that referenced this pull request Mar 15, 2018
Ports of Core's PR 7888, 8166, 8914
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request Jan 22, 2019
The latter definition was introduced by PR bitcoin#1004, the former (SipHash)
since commit 77deb4e was introduced
(rel bucash 1.1.2.0)
Bushstar pushed a commit to Bushstar/omnicore that referenced this pull request Oct 7, 2019
…nd refactor as required

938fc53 Add travis_wait to install (Peter Bushnell)
4efc40a grep -c instead of piping to wc (Peter Bushnell)
7e17795 Restore lint whitespace check (Peter Bushnell)
483755d Shellcheck updates to pass default lint-shell checks (Peter Bushnell)
d0460ec Resolve many shellcheck SC1117 warnings (Peter Bushnell)
2e690ff Restore default shebang lint test and update scripts accordingly (Peter Bushnell)
df1906f Make header guards consistent with lint header guard check (Peter Bushnell)
2536fa2 Check includes and lint circular deps (Peter Bushnell)
0f15704 Resolve lint check-rpc-mappings warnings (Peter Bushnell)

Pull request description:

Tree-SHA512: ae68486324c1d54edb1c2af690ca7d1ef22603896c152bb57c0267d5ec9119dc443f1935de78952ba91c1a32b8806ab0d0c198bfa98cf9537233cd73512e838d
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request Oct 30, 2019
c4f6665 [Build] Clean up GUI dependency checking (Fuzzbawls)

Pull request description:

  - Remove internal checks for QtSvg and QtCharts in bitcoin_qt.m4
  - Properly warn when libqrencode is missing
  - Properly warn when QtSvg is missing
  - Fix qtchartview.h path to properly detect QtCharts

  This should also resolve bitcoin#1004

ACKs for top commit:
  furszy:
    ACK [`c4f6665`](PIVX-Project@c4f6665)
  random-zebra:
    utACK c4f6665

Tree-SHA512: b287f82b168bd68c21b121f7ccd3e366bebbcabb3bbffc27bf7e49895374495bc4685a7ce9a7c7adbfb6f0b4d313d738d082458c7c829c88e435c5a9b4422063
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
EricGrill added a commit to EricGrill/litecoin that referenced this pull request Jan 14, 2026
miniupnpc API version 18 changed the signature of UPNP_GetValidIGD()
to require additional error message parameters. Add conditional
compilation to support both old and new API versions.

Fixes build failure on systems with miniupnpc >= 2.2.8:
  error: too few arguments to function 'UPNP_GetValidIGD'

Closes bitcoin#1004

Co-Authored-By: Gui-Yue <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants