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

Pruning does not respect specified disk space under bigger blocks #473

Open
ftrader opened this issue Apr 25, 2017 · 1 comment
Open

Pruning does not respect specified disk space under bigger blocks #473

ftrader opened this issue Apr 25, 2017 · 1 comment

Comments

@ftrader
Copy link
Collaborator

ftrader commented Apr 25, 2017

I raise this issue because there is something about the pruning feature that requires fixing.

The current implementation of it is based on an assumption that blocks are <= 1MB , and under this assumption it manages the disk space used "satisfactorily", shall we say.

If blocks were to become 2MB big, it could use up twice the space that the user specified.
If blocks were to become even bigger -- you see the problem.
This can obviously lead to disk space problems on nodes where space has been budgeted expressly for the Bitcoin client, and should not be exceeded.

There is no ideal fix for this, due to the construction / design of the pruning function. It currently keeps a minimum number of blocks.

If blocks get bigger, either it will have to keep less blocks as a minimum, or it will have to exceed the pruning size. Either way, it should alert the user about this condition, so that they could decide whether to increase the pruned size, or whether they are ok with keeping less bigger blocks around under their specified size constraints.

So to fix this, I plan to make the 'minimum number of blocks to keep' a configuration item, based on the current default of 288 blocks (see code in comment below).
If the pruned set (using configured minimum) exceeds the configured disk space (prune=<size> parameter) then the user should be alerted. If the disk space runs out the client should shut down safely in any case - this needs to be verified though - it might not be the case yet.

I appreciate any suggestions / input on improving upon this further.

@ftrader
Copy link
Collaborator Author

ftrader commented Apr 25, 2017

Relevant code section in main.h which describes the current assumptions / limitations:

/** Number of MiB of block files that we're trying to stay below. */        
extern uint64_t nPruneTarget;                                               
/** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of chainActive.Tip() will not be pruned. */
static const unsigned int MIN_BLOCKS_TO_KEEP = 288;                         
                                                                            
static const signed int DEFAULT_CHECKBLOCKS = MIN_BLOCKS_TO_KEEP;           
static const unsigned int DEFAULT_CHECKLEVEL = 3;                           
                                                                            
// Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat)
// At 1MB per block, 288 blocks = 288MB.                                    
// Add 15% for Undo data = 331MB                                            
// Add 20% for Orphan block rate = 397MB                                    
// We want the low water mark after pruning to be at least 397 MB and since we prune in
// full block file chunks, we need the high water mark which triggers the prune to be
// one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
// Setting the target to > than 550MB will make it likely we can respect the target.
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;

This quite good final comment shows the derivation of the 550MB documented minimum pruning size.
Of course, this goes out the window under the >1MB blocks assumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant