Panic on siad shutdown - logging after log has been closed
When shutting down siad, sometimes the following panic would occur. It's caused by the hostdb having public methods which are not protected by the threadgroup.
Caught stop signal, quitting...
Closing renter...
goroutine 1296931 [running]:
runtime/debug.Stack(0x446ab7, 0x0, 0xc47d660e88)
/usr/local/go/src/runtime/debug/stack.go:24 +0xa7
runtime/debug.PrintStack()
/usr/local/go/src/runtime/debug/stack.go:16 +0x22
gitlab.com/NebulousLabs/Sia/build.Critical(0xc47d660f38, 0x1, 0x1)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/build/critical.go:16 +0x99
gitlab.com/NebulousLabs/Sia/persist.(*closeableFile).Write(0xc42059c060, 0xc420e78000, 0x118, 0x120, 0x0, 0x0, 0x0)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/persist/log.go:114 +0x129
log.(*Logger).Output(0xc4201f2910, 0x2, 0xc43fe905a0, 0xea, 0x0, 0x0)
/usr/local/go/src/log/log.go:172 +0x1fd
gitlab.com/NebulousLabs/Sia/persist.(*Logger).Debugln(0xc420102c00, 0xc47d6614a0, 0x1, 0x1)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/persist/log.go:60 +0xa4
gitlab.com/NebulousLabs/Sia/modules/renter/hostdb.(*HostDB).priceAdjustments(0xc4204f8600, 0x1, 0x1100000, 0x3f00, 0x1100000, 0xc42181c880, 0x19, 0x803b20000000, 0x400000, 0x803b20000000, ...)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/hostdb/hostweight.go:245 +0x880
gitlab.com/NebulousLabs/Sia/modules/renter/hostdb.(*HostDB).managedCalculateHostWeightFn.func1(0x1, 0x1100000, 0x3f00, 0x1100000, 0xc42181c880, 0x19, 0x803b20000000, 0x400000, 0x803b20000000, 0x9b957acc09121309, ...)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/hostdb/hostweight.go:487 +0x220
gitlab.com/NebulousLabs/Sia/modules/renter/hostdb.(*HostDB).managedScoreBreakdown(0xc4204f8600, 0x1, 0x1100000, 0x6540, 0x1100000, 0xc421c34440, 0x17, 0x6299c800000, 0x400000, 0xa74a0000000, ...)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/hostdb/hostweight.go:517 +0x173
gitlab.com/NebulousLabs/Sia/modules/renter/hostdb.(*HostDB).ScoreBreakdown(0xc4204f8600, 0x1, 0x1100000, 0x6540, 0x1100000, 0xc421c34440, 0x17, 0x6299c800000, 0x400000, 0xa74a0000000, ...)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/hostdb/hostweight.go:504 +0x9b
gitlab.com/NebulousLabs/Sia/modules/renter/contractor.(*Contractor).managedMarkContractsUtility.func1(0xc47d663210, 0xc4204f9600, 0xc47d663120, 0x4eb77c63f074a29f)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/contractor/contractmaintenance.go:269 +0x362
gitlab.com/NebulousLabs/Sia/modules/renter/contractor.(*Contractor).managedMarkContractsUtility(0xc4204f9600, 0xbc7078, 0xc4204f9660)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/contractor/contractmaintenance.go:291 +0x4b9
gitlab.com/NebulousLabs/Sia/modules/renter/contractor.(*Contractor).threadedContractMaintenance(0xc4204f9600)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/contractor/contractmaintenance.go:693 +0x186
created by gitlab.com/NebulousLabs/Sia/modules/renter/contractor.(*Contractor).ProcessConsensusChange
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/contractor/update.go:123 +0x647
Critical error: cannot write to the file after it has been closed
Please submit a bug report here: https://gitlab.com/NebulousLabs/Sia/issues
panic: Critical error: cannot write to the file after it has been closed
Please submit a bug report here: https://gitlab.com/NebulousLabs/Sia/issues
goroutine 1296931 [running]:
gitlab.com/NebulousLabs/Sia/build.Critical(0xc47d660f38, 0x1, 0x1)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/build/critical.go:20 +0x103
gitlab.com/NebulousLabs/Sia/persist.(*closeableFile).Write(0xc42059c060, 0xc420e78000, 0x118, 0x120, 0x0, 0x0, 0x0)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/persist/log.go:114 +0x129
log.(*Logger).Output(0xc4201f2910, 0x2, 0xc43fe905a0, 0xea, 0x0, 0x0)
/usr/local/go/src/log/log.go:172 +0x1fd
gitlab.com/NebulousLabs/Sia/persist.(*Logger).Debugln(0xc420102c00, 0xc47d6614a0, 0x1, 0x1)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/persist/log.go:60 +0xa4
gitlab.com/NebulousLabs/Sia/modules/renter/hostdb.(*HostDB).priceAdjustments(0xc4204f8600, 0x1, 0x1100000, 0x3f00, 0x1100000, 0xc42181c880, 0x19, 0x803b20000000, 0x400000, 0x803b20000000, ...)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/hostdb/hostweight.go:245 +0x880
gitlab.com/NebulousLabs/Sia/modules/renter/hostdb.(*HostDB).managedCalculateHostWeightFn.func1(0x1, 0x1100000, 0x3f00, 0x1100000, 0xc42181c880, 0x19, 0x803b20000000, 0x400000, 0x803b20000000, 0x9b957acc09121309, ...)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/hostdb/hostweight.go:487 +0x220
gitlab.com/NebulousLabs/Sia/modules/renter/hostdb.(*HostDB).managedScoreBreakdown(0xc4204f8600, 0x1, 0x1100000, 0x6540, 0x1100000, 0xc421c34440, 0x17, 0x6299c800000, 0x400000, 0xa74a0000000, ...)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/hostdb/hostweight.go:517 +0x173
gitlab.com/NebulousLabs/Sia/modules/renter/hostdb.(*HostDB).ScoreBreakdown(0xc4204f8600, 0x1, 0x1100000, 0x6540, 0x1100000, 0xc421c34440, 0x17, 0x6299c800000, 0x400000, 0xa74a0000000, ...)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/hostdb/hostweight.go:504 +0x9b
gitlab.com/NebulousLabs/Sia/modules/renter/contractor.(*Contractor).managedMarkContractsUtility.func1(0xc47d663210, 0xc4204f9600, 0xc47d663120, 0x4eb77c63f074a29f)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/contractor/contractmaintenance.go:269 +0x362
gitlab.com/NebulousLabs/Sia/modules/renter/contractor.(*Contractor).managedMarkContractsUtility(0xc4204f9600, 0xbc7078, 0xc4204f9660)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/contractor/contractmaintenance.go:291 +0x4b9
gitlab.com/NebulousLabs/Sia/modules/renter/contractor.(*Contractor).threadedContractMaintenance(0xc4204f9600)
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/contractor/contractmaintenance.go:693 +0x186
created by gitlab.com/NebulousLabs/Sia/modules/renter/contractor.(*Contractor).ProcessConsensusChange
/home/cschinnerl/go/src/gitlab.com/NebulousLabs/Sia/modules/renter/contractor/update.go:123 +0x647