lovoo/goka

Panic "concurrent map read and map write" in memory storage

pachmu opened this issue · 2 comments

I'm using memory storage and sometimes I have a panic:

fatal error: concurrent map read and map write
/usr/local/Cellar/go/1.17.1/libexec/src/runtime/panic.go:1198 +0x71 fp=0xc0003e9880 sp=0xc0003e9850 pc=0x1036f31
go/1.17.1/libexec/src/runtime/map_faststr.go:116 +0x3d4 fp=0xc0003e98e8 sp=0xc0003e9880 pc=0x1014514
github.com/lovoo/goka/storage.(*memory).Get(0xc0001f6800, {0xc0016879d8, 0x2})
github.com/lovoo/goka/storage/memory.go:89 +0x31 fp=0xc0003e9918 sp=0xc0003e98e8 pc=0x1513211
github.com/lovoo/goka.(*PartitionTable).Get(0xc000128410, {0xc0016879d8, 0x2}
github.com/lovoo/goka/partition_table.go:678 +0x64 fp=0xc0003e9940 sp=0xc0003e9918 pc=0x152a264
github.com/lovoo/goka.(*View).Get(0xc0001f6800, {0xc0016879d8, 0x2})
github.com/lovoo/goka/view.go:342 +0x45 fp=0xc0003e99a8 sp=0xc0003e9940 pc=0x1537f05

I saw in the implementation of the memory storage that you don't use mutex but don't know if it was done on purpose. Wasn't it?

Hi @pachmu, to be honest I think it was not done on purpose and just never popped up, as the memory-storage is mostly used for testing. And to be honest, I'm not sure if it's very efficient, just looking at things like this.

But many thanks for the issue report!
We'll try to fix it as soon as possible. Or if you're in the mood, feel free to open a PR :)

added a lock, so the panic should be fixed.