#731·bolt

page already freed

Author: deepchCreated Sep 27, 2017Updated Jan 3, 2018

curent version git i can upload db

Linux sr7-ipeye 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Description: Ubuntu 16.04.3 LTS

func (this *Database) Clean() {
	a := []string{}
	if this.db != nil {
		this.db.Update(func(tx *bolt.Tx) error {
			start := time.Now().AddDate(0, 0, -7)
			seek := []byte(start.Format(time.RFC3339))
			c := tx.Cursor()
			for k, _ := c.Seek(seek); k != nil; k, _ = c.Next() {
				a = append(a, string(k))
			}
			return nil
		})
		if len(a) > 0 {
			for _, v := range a {
				this.db.Update(func(tx *bolt.Tx) error {
					start := time.Now().AddDate(0, 0, -7)
					seek := []byte(start.Format(time.RFC3339))
					bkt := tx.Bucket([]byte(v))
					c := bkt.Cursor()
					for k, _ := c.First(); k != nil && bytes.Compare(k, seek) <= 0; k, _ = c.Next() {
						c.Delete()
					}
					return nil
				})
			}
		}
	}
}
panic: page 1890706 already freed

goroutine 120 [running]:
github.com/boltdb/bolt.(*freelist).free(0xc420459800, 0x187c83, 0x7f01a1992000)
        /home/deepweb/test/src/github.com/boltdb/bolt/freelist.go:121 +0x301
github.com/boltdb/bolt.(*node).spill(0xc819003960, 0xc4c4119960, 0x11342e0)
        /home/deepweb/test/src/github.com/boltdb/bolt/node.go:363 +0x210
github.com/boltdb/bolt.(*node).spill(0xc7be1c0150, 0xc4c4119940, 0x11342e0)
        /home/deepweb/test/src/github.com/boltdb/bolt/node.go:350 +0xbf
github.com/boltdb/bolt.(*node).spill(0xc7be1c00e0, 0xc430fc1500, 0xc6c31b9aa8)
        /home/deepweb/test/src/github.com/boltdb/bolt/node.go:350 +0xbf
github.com/boltdb/bolt.(*Bucket).spill(0xc55f250780, 0xc430fc1400, 0xc6c31b9d20)
        /home/deepweb/test/src/github.com/boltdb/bolt/bucket.go:570 +0x4d3
github.com/boltdb/bolt.(*Bucket).spill(0xc8795ba2b8, 0x20fec8a82ccae, 0x1166ce0)
        /home/deepweb/test/src/github.com/boltdb/bolt/bucket.go:537 +0x417
github.com/boltdb/bolt.(*Tx).Commit(0xc8795ba2a0, 0x0, 0x0)
        /home/deepweb/test/src/github.com/boltdb/bolt/tx.go:163 +0x129
github.com/boltdb/bolt.(*DB).Update(0xc420210000, 0xc6c31b9f80, 0x0, 0x0)
        /home/deepweb/test/src/github.com/boltdb/bolt/db.go:605 +0xf2
main.(*Database).Clean(0xc4203ee1e0)
        /home/deepweb/test/src/github.com/deepch/dd/ModuleDatabase.go:410 +0xf2
main.event_clener()
        /home/deepweb/test/src/github.com/deepch/dd/ModuleDatabase.go:499 +0x2d
created by main.event_init
        /home/deepweb/test/src/github.com/deepch/dd/ModuleDatabase.go:494 +0x99