Pychnight / TshockRpgToolKit

Master Controller for distrubtion of quests, custom npcs, custom items and skills, housing, leveling, npcshops, etc.
GNU General Public License v2.0
11 stars 1 forks source link

[Leveling] Improve Database code / Database Issues #5

Closed Pychnight closed 7 months ago

Pychnight commented 6 years ago

image

Tim "I see a collection is being modified during enumeration. Either I've done something really stupid there, or theres another thread trying to modify the list at the same time its being saved.""

Tim "I haven't seen this bug personally yet, but I think my diagnosis is spot on. The ugly part is fixing it. Theres a lot of potential areas and ways the definition's collections could be touched by another thread. This isnt as easy as just wrapping it all in a lock. At least, I'll have to dig in and find each spot to lock. But really it needs a refactor IMO.

For now I've made an attempt to minimize it, by copying the definition before saving. Though this too suffers from the same potential issue. So for that, I'm also catching and ignoring the exception at the spot. This will ignore the save for that person's session though( until the next call to Save() ).

Leaving this open, but will need to reinvestigate."

4 this error should also be improved.

Pychnight commented 6 years ago

Secondary issues regarding databases

[Server API] Warning Plugin "TShock" has had an unhandled exception thrown by one of its ServerLeave handlers:
System.InvalidOperationException: Sequence contains no matching element
  at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x0006a] in <63992662b765477a898ef49cdcc99ee2>:0
  at Leveling.Sessions.Session.Resolve (System.Collections.Generic.IList`1[T] classes) [0x00057] in <e33190e78ff3450bbbbf0ed87a9c1fe6>:0
  at Leveling.LevelingPlugin.GetOrCreateSession (TShockAPI.TSPlayer player) [0x00050] in <e33190e78ff3450bbbbf0ed87a9c1fe6>:0
  at Leveling.LevelingPlugin.OnPlayerPermission (TShockAPI.Hooks.PlayerPermissionEventArgs args) [0x00015] in <e33190e78ff3450bbbbf0ed87a9c1fe6>:0
  at TShockAPI.Hooks.PlayerHooks.OnPlayerPermission (TShockAPI.TSPlayer player, System.String permission) [0x00011] in <ee5ce75026b74995a03fdbd3cc824395>:0
  at TShockAPI.TSPlayer.HasPermission (System.String permission) [0x00000] in <ee5ce75026b74995a03fdbd3cc824395>:0
  at TShockAPI.DB.CharacterManager.InsertPlayerData (TShockAPI.TSPlayer player) [0x00011] in <ee5ce75026b74995a03fdbd3cc824395>:0
  at TShockAPI.TShock.OnLeave (TerrariaApi.Server.LeaveEventArgs args) [0x000cb] in <ee5ce75026b74995a03fdbd3cc824395>:0
  at TerrariaApi.Server.HandlerCollection`1[ArgsType].Invoke (ArgsType args) [0x0004d] in <1498ccee3bc746fbbb4c96e1caa989d3>:0
[Server API] Warning Plugin "Leveling" has had an unhandled exception thrown by one of its ServerJoin handlers:
System.InvalidOperationException: Sequence contains no matching element
  at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x0006a] in <63992662b765477a898ef49cdcc99ee2>:0
  at Leveling.Sessions.Session.Resolve (System.Collections.Generic.IList`1[T] classes) [0x00057] in <e33190e78ff3450bbbbf0ed87a9c1fe6>:0
  at Leveling.LevelingPlugin.GetOrCreateSession (TShockAPI.TSPlayer player) [0x00050] in <e33190e78ff3450bbbbf0ed87a9c1fe6>:0
  at Leveling.LevelingPlugin.OnServerJoin (TerrariaApi.Server.JoinEventArgs args) [0x00027] in <e33190e78ff3450bbbbf0ed87a9c1fe6>:0
  at TerrariaApi.Server.HandlerCollection`1[ArgsType].Invoke (ArgsType args) [0x0004d] in <1498ccee3bc746fbbb4c96e1caa989d3>:0

seems to be happening more often in the last 2 builds of leveling on linux.

It's been frustrating as the players are unable to level... while on windows they can level up... I'm unsure how to fix this but this is a major issue