go-graphite / buckytools

Go implementation of useful tools for dealing with Graphite's Whisper DBs and Carbon hashing
Other
19 stars 8 forks source link

modify was opening as read-only but treating file as read-write #49

Closed asymmetricia closed 1 year ago

asymmetricia commented 1 year ago

Hi!

Primarily, this fixes a bug in modify wherein we open resizeFile as read-only, but then tread it as read-write (e.g., calling Truncate, and then using whisper.Create2 on it). This results in the following panic:

$ bucky modify -retention 10s:1w,5m:14d,15m:60d -f /mnt/graphite/whisper/statsite/streamstash-0002b61aedec246bf/gauges/streamstash-c/events/canceled.wsp
panic: truncate /mnt/graphite/whisper/statsite/streamstash-0002b61aedec246bf/gauges/streamstash-c/events/canceled.wsp: invalid argument

goroutine 1 [running]:
main.modifyCommand({{0x6fbb87, 0x6}, 0x72f0d0, {0x6fc85e, 0x9}, {0x70b78a, 0x2c}, {0x712d40, 0x36e}, 0xc000012840})
    /usr/local/src/github.com/go-graphite/buckytools/cmd/bucky/modify.go:84 +0x5ae
main.main()
    /usr/local/src/github.com/go-graphite/buckytools/cmd/bucky/main.go:101 +0x197

In the process, I also modify the error handling here to use log.Fatal instead of panic, but I'm happy to revert that if we have a strong preference for panic.

deniszh commented 1 year ago

log.Fatal is much better here, agreed. Thank you!