Unable to read after storage_write in Lua

Hello,
using the example code to use storage_write I get a successful write message in the log. but opening the created entry in the web view results in “An error occured while reading storage object.”. I’m using Nakama “3.17.1+c3b317d8” cockroach db “latest-v20.2”.

The code in the RPC looks like this:

    local user_id = c.SYSTEM_USER

    local new_objects = {
    { collection = "save", key = "save1", user_id = user_id, value = {name = "Hello"} }
    }

    local write_result = nk.storage_write(new_objects)
    nk.logger_info("Write result: " .. c.dump(write_result))

Log message after write:

{"level":"info","ts":"2023-10-18T16:11:40.454Z","caller":"server/runtime_lua_nakama.go:2249","msg":"Write
result: { [1] = { [\"key\"] = save1,[\"collection\"] = save,[\"user_id\"] = 00000000-0000-0000-0000-0000
00000000,[\"version\"] = b07f9e832eb35ecaf98ea12e25227df4,} ,} ","runtime":"lua","rpc_id":"save_receipt"}

Log message when opening the entry in the web view:

{"level":"error","ts":"2023-10-18T16:12:15.257Z","caller":"server/core_storage.go:494","msg":"Could not r
ead storage objects.","error":"cannot convert [save] to Text"}

Please see: Could not read storage objects on first read of collection, update the CRBD version and try again.

If you’re using a docker-compose file from our docs please let us know where from so we can update the CRBD version there too.

Thanks for the response. I based my docker-compose on the one found here - that was some months ago, tough. I checked yesterday to see if I should update (as I remembered that thread you linked, but not the version that was the correct solution), but it still said

image: cockroachdb/cockroach:latest-v20.2

I updated to 22.1 and reading the object works correctly now. Is there a CRDB version you recommend for Nakama 3.17.1?

Also note for others aiming to update their CRDB version: you have to update through the major versions as shown here. Directly jumping to a later version does not work.

Thanks @anteaters, @gabriel can we please update the CRDB version there :pray:?

Updated the docs - thanks both :bowing_man:

@anteaters For the future, you can always see the recommended version directly in GH: https://github.com/heroiclabs/nakama/blob/master/docker-compose.yml (but we’ll also make sure the docs stay current as well :slight_smile: )

2 Likes