{"action":"created","issue":{"url":"https://api.github.com/repos/boltdb/bolt/issues/348","labels_url":"https://api.github.com/repos/boltdb/bolt/issues/348/labels{/name}","comments_url":"https://api.github.com/repos/boltdb/bolt/issues/348/comments","events_url":"https://api.github.com/repos/boltdb/bolt/issues/348/events","html_url":"https://github.com/boltdb/bolt/issues/348","id":67865869,"number":348,"title":"panic: page 87 already freed","user":{"login":"davecgh","id":2115102,"avatar_url":"https://avatars.githubusercontent.com/u/2115102?v=3","gravatar_id":"","url":"https://api.github.com/users/davecgh","html_url":"https://github.com/davecgh","followers_url":"https://api.github.com/users/davecgh/followers","following_url":"https://api.github.com/users/davecgh/following{/other_user}","gists_url":"https://api.github.com/users/davecgh/gists{/gist_id}","starred_url":"https://api.github.com/users/davecgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecgh/subscriptions","organizations_url":"https://api.github.com/users/davecgh/orgs","repos_url":"https://api.github.com/users/davecgh/repos","events_url":"https://api.github.com/users/davecgh/events{/privacy}","received_events_url":"https://api.github.com/users/davecgh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-12T03:24:31Z","updated_at":"2015-07-22T03:30:45Z","closed_at":null,"body":"I've been doing a bit of corruption testing under unexpected power off scenarios (using an external USB drive and disconnecting it midstream) and, unfortunately, I'm fairly consistently hitting unrecoverable database corruption issues due to things such as `unreachable unfreed` or `already freed`.  I understand write corruption in this scenario is expected, but the database shouldn't be left in an unrecoverable state.\r\n\r\nEDIT: I should also note this is on Windows 7 using all default bolt options.\r\n\r\nI have a 4KiB database that is corrupted from this scenario that I'll keep around to help debug.  To get started, I'm providing the following pertinent details:\r\n- A trace of the panic.  NOTE: The trace is from a vendored version of bolt, but there are no code modifications and it is synced through commit ee954308d64186f0fc9b7022b6178977848c17a3.\r\n- Output of the `bolt pages` command\r\n- Output of the `bolt check` command.  **NOTE: This command hangs and never completes**\r\n\r\n```\r\ngoroutine 12 [running]:\r\ngithub.com/btcsuite/bolt.(*freelist).free(0xc08202b680, 0xca2, 0x2af7000)\r\n       .../bolt/freelist.go:118 +0x35c\r\ngithub.com/btcsuite/bolt.(*node).spill(0xc0820e2380, 0x0, 0x0)\r\n        .../bolt/node.go:349 +0x280\r\ngithub.com/btcsuite/bolt.(*node).spill(0xc0820e2310, 0x0, 0x0)\r\n        .../bolt/node.go:336 +0x134\r\ngithub.com/btcsuite/bolt.(*node).spill(0xc0820e22a0, 0x0, 0x0)\r\n        .../bolt/node.go:336 +0x134\r\ngithub.com/btcsuite/bolt.(*Bucket).spill(0xc0820dc7c0, 0x0, 0x0)\r\n        .../bolt/bucket.go:536 +0x1cb\r\ngithub.com/btcsuite/bolt.(*Bucket).spill(0xc0820dc780, 0x0, 0x0)\r\n        .../bolt/bucket.go:503 +0xac9\r\ngithub.com/btcsuite/bolt.(*Bucket).spill(0xc0820e65c8, 0x0, 0x0)\r\n        .../bolt/bucket.go:503 +0xac9\r\ngithub.com/btcsuite/bolt.(*Tx).Commit(0xc0820e65b0, 0x0, 0x0)\r\n        .../bolt/tx.go:150 +0x1f5\r\n...\r\n```\r\n\r\n```bash\r\n$ bolt pages test.db\r\n\r\nID       TYPE       ITEMS  OVRFLW\r\n======== ========== ====== ======\r\n0        meta       0            \r\n1        meta       0            \r\n2        leaf       14           \r\n3        leaf       19           \r\n4        leaf       19           \r\n5        leaf       17           \r\n6        leaf       17           \r\n7        leaf       27           \r\n8        leaf       22           \r\n9        leaf       17           \r\n10       leaf       17           \r\n11       leaf       15           \r\n12       leaf       19           \r\n13       leaf       26           \r\n14       leaf       14           \r\n15       leaf       17           \r\n16       leaf       25           \r\n17       leaf       17           \r\n18       leaf       16           \r\n19       leaf       22           \r\n20       leaf       17           \r\n21       leaf       15           \r\n22       leaf       27           \r\n23       leaf       22           \r\n24       leaf       16           \r\n25       leaf       16           \r\n26       leaf       24           \r\n27       leaf       24           \r\n28       leaf       27           \r\n29       leaf       23           \r\n30       leaf       23           \r\n31       leaf       18           \r\n32       leaf       26           \r\n33       leaf       16           \r\n34       leaf       22           \r\n35       leaf       16           \r\n36       leaf       25           \r\n37       leaf       19           \r\n38       leaf       23           \r\n39       leaf       14           \r\n40       leaf       25           \r\n41       leaf       28           \r\n42       leaf       16           \r\n43       leaf       16           \r\n44       leaf       16           \r\n45       leaf       20           \r\n46       leaf       18           \r\n47       leaf       26           \r\n48       leaf       18           \r\n49       leaf       24           \r\n50       leaf       28           \r\n51       leaf       23           \r\n52       leaf       21           \r\n53       leaf       18           \r\n54       leaf       24           \r\n55       leaf       20           \r\n56       leaf       27           \r\n57       leaf       18           \r\n58       leaf       18           \r\n59       leaf       23           \r\n60       leaf       28           \r\n61       leaf       26           \r\n62       leaf       17           \r\n63       leaf       16           \r\n64       leaf       26           \r\n65       leaf       19           \r\n66       leaf       15           \r\n67       leaf       14           \r\n68       leaf       17           \r\n69       leaf       18           \r\n70       leaf       27           \r\n71       leaf       21           \r\n72       leaf       23           \r\n73       leaf       16           \r\n74       leaf       19           \r\n75       leaf       23           \r\n76       leaf       19           \r\n77       leaf       21           \r\n78       leaf       17           \r\n79       leaf       24           \r\n80       leaf       25           \r\n81       leaf       16           \r\n82       leaf       27           \r\n83       leaf       15           \r\n84       leaf       21           \r\n85       leaf       22           \r\n86       leaf       23           \r\n87       freelist   6            \r\n88       leaf       16           \r\n89       leaf       15           \r\n90       leaf       22           \r\n91       leaf       19           \r\n92       leaf       14           \r\n93       leaf       18           \r\n94       leaf       19           \r\n95       leaf       18           \r\n96       leaf       21           \r\n97       leaf       23           \r\n98       leaf       19           \r\n99       leaf       25           \r\n100      leaf       19           \r\n101      leaf       17           \r\n102      leaf       22           \r\n103      leaf       16           \r\n104      leaf       25           \r\n105      leaf       20           \r\n106      leaf       17           \r\n107      leaf       22           \r\n108      leaf       15           \r\n109      leaf       16           \r\n110      leaf       21           \r\n111      leaf       15           \r\n112      leaf       14           \r\n113      leaf       27           \r\n114      leaf       17           \r\n115      leaf       15           \r\n116      leaf       21           \r\n117      leaf       26           \r\n118      leaf       26           \r\n119      leaf       22           \r\n120      leaf       20           \r\n121      leaf       16           \r\n122      leaf       25           \r\n123      leaf       15           \r\n124      leaf       18           \r\n125      leaf       18           \r\n126      leaf       16           \r\n127      leaf       28           \r\n128      leaf       18           \r\n129      leaf       17           \r\n130      leaf       19           \r\n131      leaf       25           \r\n132      leaf       26           \r\n133      leaf       24           \r\n134      leaf       18           \r\n135      leaf       26           \r\n136      leaf       20           \r\n137      leaf       18           \r\n138      leaf       23           \r\n139      leaf       26           \r\n140      leaf       15           \r\n141      leaf       17           \r\n142      leaf       24           \r\n143      leaf       16           \r\n144      leaf       16           \r\n145      leaf       22           \r\n146      leaf       15           \r\n147      leaf       18           \r\n148      leaf       26           \r\n149      leaf       14           \r\n150      leaf       14           \r\n151      leaf       14           \r\n152      leaf       15           \r\n153      leaf       15           \r\n154      leaf       17           \r\n155      leaf       27           \r\n156      leaf       22           \r\n157      branch     80           \r\n158      leaf       15           \r\n159      leaf       15           \r\n160      leaf       15           \r\n161      leaf       15           \r\n162      leaf       15           \r\n163      leaf       15           \r\n164      branch     42           \r\n165      branch     45           \r\n166      free                    \r\n167      branch     4            \r\n168      free                    \r\n169      leaf       2            \r\n170      leaf       1            \r\n171      free                    \r\n172      free                    \r\n173      free                    \r\n174      free                    \r\n```\r\n\r\n```\r\n$ bolt check test.db\r\npage 87: reachable freed\r\npage 105: multiple references\r\npage 83: multiple references\r\npage 87: multiple references\r\npage 87: reachable freed\r\npage 97: multiple references\r\npage 97: multiple references\r\npage 97: multiple references\r\npage 157: multiple references\r\npage 21: multiple references\r\npage 20: multiple references\r\npage 87: multiple references\r\npage 87: reachable freed\r\npage 27: multiple references\r\npage 35: multiple references\r\npage 129: multiple references\r\npage 132: multiple references\r\npage 156: multiple references\r\npage 82: multiple references\r\npage 80: multiple references\r\npage 139: multiple references\r\npage 60: multiple references\r\npage 121: multiple references\r\npage 153: multiple references\r\npage 30: multiple references\r\npage 7: multiple references\r\npage 112: multiple references\r\npage 9: multiple references\r\npage 127: multiple references\r\npage 118: multiple references\r\npage 74: multiple references\r\npage 106: multiple references\r\npage 15: multiple references\r\npage 78: multiple references\r\npage 65: multiple references\r\npage 39: multiple references\r\npage 159: multiple references\r\npage 63: multiple references\r\npage 124: multiple references\r\npage 107: multiple references\r\npage 3: multiple references\r\npage 16: multiple references\r\npage 67: multiple references\r\npage 163: multiple references\r\npage 29: multiple references\r\npage 92: multiple references\r\npage 105: multiple references\r\npage 105: multiple references\r\npage 13: multiple references\r\npage 85: multiple references\r\npage 109: multiple references\r\npage 137: multiple references\r\npage 48: multiple references\r\npage 138: multiple references\r\npage 75: multiple references\r\npage 28: multiple references\r\npage 83: multiple references\r\npage 55: multiple references\r\npage 32: multiple references\r\npage 34: multiple references\r\npage 84: multiple references\r\npage 51: multiple references\r\npage 53: multiple references\r\npage 126: multiple references\r\npage 19: multiple references\r\npage 23: multiple references\r\npage 95: multiple references\r\npage 96: multiple references\r\npage 5: multiple references\r\npage 37: multiple references\r\npage 130: multiple references\r\npage 149: multiple references\r\npage 161: multiple references\r\npage 72: multiple references\r\npage 73: multiple references\r\npage 116: multiple references\r\npage 113: multiple references\r\npage 18: multiple references\r\npage 125: multiple references\r\npage 146: multiple references\r\npage 102: multiple references\r\npage 134: multiple references\r\npage 76: multiple references\r\npage 114: multiple references\r\npage 62: multiple references\r\npage 66: multiple references\r\npage 103: multiple references\r\npage 97: multiple references\r\npage 83: multiple references\r\npage 87: multiple references\r\npage 87: reachable freed\r\n**Hangs here and never completes** \r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/boltdb/bolt/issues/comments/123552614","html_url":"https://github.com/boltdb/bolt/issues/348#issuecomment-123552614","issue_url":"https://api.github.com/repos/boltdb/bolt/issues/348","id":123552614,"user":{"login":"nicpottier","id":168067,"avatar_url":"https://avatars.githubusercontent.com/u/168067?v=3","gravatar_id":"","url":"https://api.github.com/users/nicpottier","html_url":"https://github.com/nicpottier","followers_url":"https://api.github.com/users/nicpottier/followers","following_url":"https://api.github.com/users/nicpottier/following{/other_user}","gists_url":"https://api.github.com/users/nicpottier/gists{/gist_id}","starred_url":"https://api.github.com/users/nicpottier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicpottier/subscriptions","organizations_url":"https://api.github.com/users/nicpottier/orgs","repos_url":"https://api.github.com/users/nicpottier/repos","events_url":"https://api.github.com/users/nicpottier/events{/privacy}","received_events_url":"https://api.github.com/users/nicpottier/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T03:30:44Z","updated_at":"2015-07-22T03:30:44Z","body":"I've also run into this stress testing.. but in my case I'm going against an SSD on OSX. What can I provide to help debug? I still have the db, but it is 2 gigs.."}}