Commit 6ff34e8
committed
fix(blockvalidation): release pooled txMap on every Block.Valid exit path
Address PR bsv-blockchain#886 review (Copilot + claude-code-review confirmed Major):
the pooled txMap allocated inside checkDuplicateTransactions was only
returned to the size-class pool on the success path. Any error between
the allocation and the final cleanup (a checkDuplicateTransactions
worker error, the txMap.Flush failure, or any validOrderAndBlessed
error) returned from Block.Valid with b.txMap still pointing at the
multi-GB pooled instance. At 654M-tx scale each leaked map pins ~30 GB
of backing storage on the Block until GC, which may not run for a
long time if the Block is held by the lastValidatedBlocks cache.
Extract the cleanup into a (b *Block).releaseTxMap helper (nil-safe,
idempotent, handles disk-backed / pooled-in-memory / generic Closer)
and call it via `defer` from Block.Valid immediately before invoking
checkDuplicateTransactions. The defer fires on every exit path, so
errors no longer leak the map.
Also address Copilot Minor on batchKeysPool: document the workload
assumption (uniform SetMinedMulti batch sizes within a single Store's
lifetime) and explain when size-class bucketing would become necessary.1 parent 63888c4 commit 6ff34e8
2 files changed
Lines changed: 35 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
540 | 549 | | |
541 | 550 | | |
542 | 551 | | |
| |||
570 | 579 | | |
571 | 580 | | |
572 | 581 | | |
573 | | - | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
574 | 595 | | |
575 | 596 | | |
576 | 597 | | |
577 | 598 | | |
578 | 599 | | |
579 | 600 | | |
580 | | - | |
581 | | - | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
582 | 604 | | |
583 | 605 | | |
584 | 606 | | |
585 | 607 | | |
586 | 608 | | |
587 | 609 | | |
588 | | - | |
589 | 610 | | |
590 | | - | |
| 611 | + | |
591 | 612 | | |
592 | 613 | | |
593 | 614 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
112 | 121 | | |
113 | 122 | | |
114 | 123 | | |
| |||
0 commit comments