Gossip Gloomers: SeqKV returning error due to missing "src" key

For the Challenge #4: Grow-Only Counter · Fly Docs challenge, I’m trying to read value of key key from seq-kv node, but it’s erroring out

clojure.lang.ExceptionInfo: Malformed network message. Node n1 tried to send the following message via STDOUT:

{:dest "seq-kv", :body {:key "key", :msg_id 1, :type "read"}}

This is malformed because:

{:src missing-required-key}

It seems src is missing, although I’m initializing it as follows:

	node := maelstrom.NewNode()
	seqConsistentKV := maelstrom.NewSeqKV(node)

and I tried moving maelstrom.NewSeqKV(node) inside the RPC in case the node ID gets copied somewhere (before init RPC runs), but that doesn’t seem to be the case either.

According to node log, the requests to dest: seq-kv don’t have a src field:

2023/03/01 13:17:52 Received {c1 n2 {"type":"init","node_id":"n2","node_ids":["n0","n1","n2"],"msg_id":1}}
2023/03/01 13:17:52 Node n2 initialized
2023/03/01 13:17:52 Sent {"src":"n2","dest":"c1","body":{"in_reply_to":1,"type":"init_ok"}}
2023/03/01 13:17:54 Received {c7 n2 {"type":"read","msg_id":1}}
2023/03/01 13:17:54 Sent {"dest":"seq-kv","body":{"key":"key","msg_id":1,"type":"read"}}  <--- no src
2023/03/01 13:17:59 Received {c10 n2 {"type":"read","msg_id":1}}
2023/03/01 13:17:59 Sent {"dest":"seq-kv","body":{"key":"key","msg_id":2,"type":"read"}}  <--- no src
2023/03/01 13:18:04 Received {c13 n2 {"type":"read","msg_id":1}}

Actually looking more closely into the code, KV.Read() calls Node.SyncRPC(), which calls Node.RPC(), which calls Node.Send() and I see Node.id field being used as src there, and this is after node initialization happens, so I’m not sure what’s happening.

Can you post a gist of your code?

Here it is: main.go · GitHub

Argh I think I had contention between multiple node variables and one didn’t have the ID. My bad.

1 Like