Stackerstan/mindmachine

Problem: fatal error: concurrent map iteration and map write

stanstacks opened this issue · 0 comments

Steps to reproduce:
Add more than one relay to the config file,
Execute make reset

It doesn't throw this error every time but it does it often.

 INFO => Doki Mind has started
 INFO => Samizdat Mind has started
 INFO => Conductor: I'm now accepting Events
 INFO => Nostrelay upserting b22ddf824cc4fc0824c65393488bd47a3a7ef841ae2f04d91853ee80f08cda66

fatal error: concurrent map iteration and map write
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

runtime.throw({0x14f81ce?, 0xc0006c0000?})
        /usr/local/Cellar/go/1.18/libexec/src/runtime/panic.go:992 +0x71 fp=0xc0000c49d8 sp=0xc0000c49a8 pc=0x1033f91
runtime.mapiternext(0x14556e0?)
        /usr/local/Cellar/go/1.18/libexec/src/runtime/map.go:871 +0x4eb fp=0xc0000c4a48 sp=0xc0000c49d8 pc=0x1010ccb
reflect.mapiternext(0x108f3ef?)
        /usr/local/Cellar/go/1.18/libexec/src/runtime/map.go:1378 +0x19 fp=0xc0000c4a60 sp=0xc0000c4a48 pc=0x105dc59
reflect.(*MapIter).Next(0xc000537d40?)
        /usr/local/Cellar/go/1.18/libexec/src/reflect/value.go:1787 +0x7e fp=0xc0000c4a90 sp=0xc0000c4a60 pc=0x108f4be
encoding/json.mapEncoder.encode({0xc000206080?}, 0xc000206080, {0x146cd40?, 0xc000134480?, 0x146cd40?}, {0x88?, 0x3b?})
        /usr/local/Cellar/go/1.18/libexec/src/encoding/json/encode.go:799 +0x2d4 fp=0xc0000c4c50 sp=0xc0000c4a90 pc=0x1278ad4
encoding/json.mapEncoder.encode-fm(0x146cd40?, {0x146cd40?, 0xc000134480?, 0x30?}, {0xb8?, 0xb5?})
        <autogenerated>:1 +0x45 fp=0xc0000c4c90 sp=0xc0000c4c50 pc=0x1282845
encoding/json.(*encodeState).reflectValue(0x0?, {0x146cd40?, 0xc000134480?, 0x100e607?}, {0x78?, 0x0?})
        /usr/local/Cellar/go/1.18/libexec/src/encoding/json/encode.go:360 +0x78 fp=0xc0000c4cf0 sp=0xc0000c4c90 pc=0x12760d8
encoding/json.(*encodeState).marshal(0x203000?, {0x146cd40?, 0xc000134480?}, {0x1a?, 0x0?})
        /usr/local/Cellar/go/1.18/libexec/src/encoding/json/encode.go:332 +0xfa fp=0xc0000c4d68 sp=0xc0000c4cf0 pc=0x1275d1a
encoding/json.Marshal({0x146cd40, 0xc000134480})
        /usr/local/Cellar/go/1.18/libexec/src/encoding/json/encode.go:161 +0x45 fp=0xc0000c4dc8 sp=0xc0000c4d68 pc=0x12753a5
encoding/json.MarshalIndent({0x146cd40?, 0xc000134480?}, {0x0, 0x0}, {0x168f070, 0x1})
        /usr/local/Cellar/go/1.18/libexec/src/encoding/json/encode.go:176 +0x4a fp=0xc0000c4e40 sp=0xc0000c4dc8 pc=0x12754ea


mindmachine/messaging/nostrelay.persist()
        /Users/stan/git/stackerstan/mindmachine/messaging/nostrelay/database.go:93
^^^^^^^^^^^^^^^^^^^^^^^^

mindmachine/messaging/nostrelay.FetchEventPack({0xc0000c5ac0, 0x1, 0x1?})
        /Users/stan/git/stackerstan/mindmachine/messaging/nostrelay/fetchEvents.go:129 +0x667 fp=0xc0000c5968 sp=0xc0000c4ea0 pc=0x1396587
mindmachine/messaging/eventcatcher.subscribeToSamizdat()
        /Users/stan/git/stackerstan/mindmachine/messaging/eventcatcher/eventcatcher.go:295 +0x76 fp=0xc0000c5c48 sp=0xc0000c5968 pc=0x1412c36
mindmachine/messaging/eventcatcher.Start(0xc00007e000?, 0xc0000240b0?)
        /Users/stan/git/stackerstan/mindmachine/messaging/eventcatcher/eventcatcher.go:41 +0x1a5 fp=0xc0000c5f88 sp=0xc0000c5c48 pc=0x1410205
main.startMinds(0x1420feb?, 0x1421ba6?, 0x0?)
        /Users/stan/git/stackerstan/mindmachine/cmd/mindmachine/main.go:153 +0x34 fp=0xc0000c5fb8 sp=0xc0000c5f88 pc=0x1421c14
main.main.func2()
        /Users/stan/git/stackerstan/mindmachine/cmd/mindmachine/main.go:106 +0x2e fp=0xc0000c5fe0 sp=0xc0000c5fb8 pc=0x1421b4e
runtime.goexit()
        /usr/local/Cellar/go/1.18/libexec/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0000c5fe8 sp=0xc0000c5fe0 pc=0x1063d81
created by main.main
        /Users/stan/git/stackerstan/mindmachine/cmd/mindmachine/main.go:106 +0x438