Page MenuHomePhabricator

blockstorage: Adjust fastprune limit if block exceeds blockfile size
ClosedPublic

Authored by PiRK on Fri, Apr 19, 11:37.

Details

Summary

If the added block exceeds the blockfile size in test-only
-fastprune mode, the node would get stuck in an infinite loop and
run out of memory.

Avoid this by raising the blockfile size to the size of the added block
in this situation.

Co-authored-by: TheCharlatan <seb.kung@gmail.com>

This is a backport of core#27191

Depends on D16028

Note that this fix does not address the non-test issue of blocks larger than 128 MiB. But at least now we get a meaningful assertion failure rather than an OOM crash.

Test Plan

ninja all check-all

Check that without the change in blockstorage.cpp the new test slowly consumes all the memory and the test eventually fails.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Failed tests logs:

====== Bitcoin ABC functional tests: feature_fastprune.py ======

------- Stdout: -------
2024-04-19T11:46:52.860000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_₿₵_  _20240419_114357/feature_fastprune_263
2024-04-19T11:46:53.133000Z TestFramework (INFO): ensure that large blocks don't crash or freeze in -fastprune
2024-04-19T11:46:53.133000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 147, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 137, in _run_test_internal
    self.run_test()
  File "/work/test/functional/feature_fastprune.py", line 24, in run_test
    tx = wallet.create_self_transfer()["tx"]
  File "/work/test/functional/test_framework/wallet.py", line 160, in create_self_transfer
    utxo_to_spend = utxo_to_spend or self.get_utxo()
  File "/work/test/functional/test_framework/wallet.py", line 127, in get_utxo
    index = self._utxos.index(next(utxo_filter))
StopIteration
2024-04-19T11:46:53.184000Z TestFramework (INFO): Stopping nodes
2024-04-19T11:46:53.385000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_₿₵_  _20240419_114357/feature_fastprune_263
2024-04-19T11:46:53.385000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_₿₵_  _20240419_114357/feature_fastprune_263/test_framework.log
2024-04-19T11:46:53.386000Z TestFramework (ERROR): 
2024-04-19T11:46:53.386000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_₿₵_  _20240419_114357/feature_fastprune_263' to consolidate all logs
2024-04-19T11:46:53.386000Z TestFramework (ERROR): 
2024-04-19T11:46:53.386000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2024-04-19T11:46:53.386000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2024-04-19T11:46:53.386000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: feature_fastprune.py

Failed tests logs:

====== Bitcoin ABC functional tests: feature_fastprune.py ======

------- Stdout: -------
2024-04-19T11:50:20.182000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20240419_114236/feature_fastprune_263
2024-04-19T11:50:20.765000Z TestFramework (INFO): ensure that large blocks don't crash or freeze in -fastprune
2024-04-19T11:50:20.765000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 147, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 137, in _run_test_internal
    self.run_test()
  File "/work/test/functional/feature_fastprune.py", line 24, in run_test
    tx = wallet.create_self_transfer()["tx"]
  File "/work/test/functional/test_framework/wallet.py", line 160, in create_self_transfer
    utxo_to_spend = utxo_to_spend or self.get_utxo()
  File "/work/test/functional/test_framework/wallet.py", line 127, in get_utxo
    index = self._utxos.index(next(utxo_filter))
StopIteration
2024-04-19T11:50:20.816000Z TestFramework (INFO): Stopping nodes
2024-04-19T11:50:20.918000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20240419_114236/feature_fastprune_263
2024-04-19T11:50:20.918000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20240419_114236/feature_fastprune_263/test_framework.log
2024-04-19T11:50:20.918000Z TestFramework (ERROR): 
2024-04-19T11:50:20.918000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20240419_114236/feature_fastprune_263' to consolidate all logs
2024-04-19T11:50:20.918000Z TestFramework (ERROR): 
2024-04-19T11:50:20.918000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2024-04-19T11:50:20.918000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2024-04-19T11:50:20.918000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: feature_fastprune.py

Failed tests logs:

====== Bitcoin ABC functional tests: feature_fastprune.py ======

------- Stdout: -------
2024-04-19T11:49:16.716000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20240419_114450/feature_fastprune_263
2024-04-19T11:49:17.017000Z TestFramework (INFO): ensure that large blocks don't crash or freeze in -fastprune
2024-04-19T11:49:17.017000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 147, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 137, in _run_test_internal
    self.run_test()
  File "/work/test/functional/feature_fastprune.py", line 24, in run_test
    tx = wallet.create_self_transfer()["tx"]
  File "/work/test/functional/test_framework/wallet.py", line 160, in create_self_transfer
    utxo_to_spend = utxo_to_spend or self.get_utxo()
  File "/work/test/functional/test_framework/wallet.py", line 127, in get_utxo
    index = self._utxos.index(next(utxo_filter))
StopIteration
2024-04-19T11:49:17.068000Z TestFramework (INFO): Stopping nodes
2024-04-19T11:49:17.169000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20240419_114450/feature_fastprune_263
2024-04-19T11:49:17.169000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20240419_114450/feature_fastprune_263/test_framework.log
2024-04-19T11:49:17.169000Z TestFramework (ERROR): 
2024-04-19T11:49:17.170000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20240419_114450/feature_fastprune_263' to consolidate all logs
2024-04-19T11:49:17.170000Z TestFramework (ERROR): 
2024-04-19T11:49:17.170000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2024-04-19T11:49:17.170000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2024-04-19T11:49:17.170000Z TestFramework (ERROR):
====== Bitcoin ABC functional tests with the next upgrade activated: feature_fastprune.py ======

------- Stdout: -------
2024-04-19T11:53:33.512000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20240419_114918/feature_fastprune_263
2024-04-19T11:53:33.814000Z TestFramework (INFO): ensure that large blocks don't crash or freeze in -fastprune
2024-04-19T11:53:33.814000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 147, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 137, in _run_test_internal
    self.run_test()
  File "/work/test/functional/feature_fastprune.py", line 24, in run_test
    tx = wallet.create_self_transfer()["tx"]
  File "/work/test/functional/test_framework/wallet.py", line 160, in create_self_transfer
    utxo_to_spend = utxo_to_spend or self.get_utxo()
  File "/work/test/functional/test_framework/wallet.py", line 127, in get_utxo
    index = self._utxos.index(next(utxo_filter))
StopIteration
2024-04-19T11:53:33.865000Z TestFramework (INFO): Stopping nodes
2024-04-19T11:53:33.966000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20240419_114918/feature_fastprune_263
2024-04-19T11:53:33.966000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20240419_114918/feature_fastprune_263/test_framework.log
2024-04-19T11:53:33.966000Z TestFramework (ERROR): 
2024-04-19T11:53:33.967000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20240419_114918/feature_fastprune_263' to consolidate all logs
2024-04-19T11:53:33.967000Z TestFramework (ERROR): 
2024-04-19T11:53:33.967000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2024-04-19T11:53:33.967000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2024-04-19T11:53:33.967000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: feature_fastprune.py
Bitcoin ABC functional tests with the next upgrade activated: feature_fastprune.py

rebase after backporting all the pieces needed for the new test, squash with https://github.com/bitcoin/bitcoin/pull/27553

PiRK published this revision for review.Fri, Apr 19, 13:50
PiRK edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Fri, Apr 19, 14:22