Skip to content
Snippets Groups Projects
Commit 65dd63b8 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Modify the fallback logic in receiveHelper to work even if we don't get errors...

Modify the fallback logic in receiveHelper to work even if we don't get errors like we expect from it
parent 8b3910d3
Branches
Tags
2 merge requests!60Revert "Fail a test to be sure it works",!10Make the message id index unique
...@@ -382,16 +382,21 @@ func (w *wasmModel) receiveHelper(newMessage *Message) (uint64, ...@@ -382,16 +382,21 @@ func (w *wasmModel) receiveHelper(newMessage *Message) (uint64,
err = txn.Await(ctx) err = txn.Await(ctx)
cancel() cancel()
if err != nil { if err != nil {
err = errors.Errorf("Upserting Message failed: %+v", err) return 0, errors.Errorf("Upserting Message failed: %+v", err)
}
res, err := addReq.Result()
// NOTE: Sometimes the insert fails to return an error but hits
// a duplicate insert, so this fallthrough returns the uuid entry in
// that case.
if res.IsUndefined() {
msgID := cryptoChannel.MessageID{} msgID := cryptoChannel.MessageID{}
copy(msgID[:], newMessage.MessageID) copy(msgID[:], newMessage.MessageID)
uuid, _ := w.msgIDLookup(msgID) uuid, errLookup := w.msgIDLookup(msgID)
if uuid == 0 { if uuid != 0 && errLookup == nil {
return uuid, nil return uuid, nil
} }
return 0, err return 0, errors.Errorf("uuid lookup failure: %+v", err)
} }
res, _ := addReq.Result()
uuid := uint64(res.Int()) uuid := uint64(res.Int())
jww.DEBUG.Printf( jww.DEBUG.Printf(
"Successfully stored message from %s, id %d", "Successfully stored message from %s, id %d",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment