heroiclabs / nakama

Distributed server for social and realtime games and apps.
https://heroiclabs.com
Apache License 2.0
9.01k stars 1.1k forks source link

Error when writing leaderboard record: sql: no rows in result set #709

Closed krigus closed 3 years ago

krigus commented 3 years ago

Description

When writing a leaderboard record for an authoritative leaderboard from a LUA-module, an error is sometimes thrown: "Error when writing leaderboard record: sql: no rows in result set"

Leaderboard settings (lua): authoritative = true sort = "desc" operator = "best" reset = nil

It seems to happen occasionally, I haven't found a pattern for when it fails, could be a timing issue. The lua module I'm using to write is simply a wrapper of the following call:

local success, result = pcall(nk.leaderboard_record_write, json.lbId, ctx.user_id, ctx.username, json.score, json.subscore, json.metadata)

Steps to Reproduce

  1. Create a new leaderboard with the settings above
  2. Submit regular leaderboard records from a lua module for a specific user (every 2 minutes in my case) with the same score and parameters every time
  3. Observe the error eventually

Expected Result

No error is thrown and the score is handled according to the "best" operator.

Actual Result

2021-11-03 17:22:25    DEBUG |  nakama  | Leaderboard haystack lookup  
2021-11-03 17:22:25    WARN |  nakama  | Failed to write leaderboard character_level_warrior_standard for: 1fd68bb8-0ed5-41f9-89d4-27d010aaf72c: "/nakama/data/modules/leaderboards.lua:182: error writing leaderboard record: sql: no rows in result set"  
**2021-11-03 17:22:25    ERROR |  nakama  | Error writing leaderboard recordsql: no rows in result set** 
2021-11-03 17:22:25    WARN |  nakama  | Failed to write leaderboard character_level_overall_standard for: 1fd68bb8-0ed5-41f9-89d4-27d010aaf72c: "/nakama/data/modules/leaderboards.lua:182: error writing leaderboard record: sql: no rows in result set"  
2021-11-03 17:22:25    ERROR |  nakama  | Error writing leaderboard recordsql: no rows in result set 
2021-11-03 17:21:43    DEBUG |  nakama  | Leaderboard haystack lookup  
2021-11-03 17:21:43    INFO |  nakama  | Wrote leaderboard character_level_warrior_standard for: 1fd68bb8-0ed5-41f9-89d4-27d010aaf72c

Context

Your Environment

zyro commented 3 years ago

Thanks for reporting! Fixed in e4ddde59a4f1003d6f36422ece370083be77d7c8 and will be part of the next release. 👍