ValheimPlus icon indicating copy to clipboard operation
ValheimPlus copied to clipboard

[BUG] Chest emptied when auto deposit honey turned on - intermittent issue

Open ohrickster opened this issue 3 years ago • 6 comments

  • OS: Windows Client or Server
  • Valheim Game Version: 0.206.5
  • V+ Mod Version: [Valheim Plus 0.9.9.7]

Twice I have been playing with the configuration of auto-deposit of honey from hives into a nearby chest. Most of the time this works flawlessly however, I believe when the chest is full, (chests extended) the chest is emptied the next time it is opened. The first time this happened was on a windows server (dedicated headless client) and the second time was a solo windows client.

I had just made serpent stew which requires mushrooms and I know I had mushrooms in that chest. I opened the chest to deposit some more supplies and the only thing left in there was honey.

To Reproduce I am not sure what is triggering this and I have seen it happen twice but have not been able to manually reproduce it.

Configuration: https://pastebin.com/dZCPcm3c

Additional context

The only other mod I have installed is the "ore support" mod

ohrickster avatar Feb 07 '22 00:02 ohrickster

Single-player or Multi-player ?

nxPublic avatar Feb 07 '22 09:02 nxPublic

I've seen this issue happen on a single-player world (local windows client) and a multi-player dedicated server but have not been able to duplicate it manually. I'm attempting to replicate it by filling a chest with stones and leaving a few slots open for honey deposit to see if it happens again.

On Mon, Feb 7, 2022 at 4:32 AM nX_ @.***> wrote:

Single-player or Multi-player ?

— Reply to this email directly, view it on GitHub https://github.com/valheimPlus/ValheimPlus/issues/675#issuecomment-1031253769, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHCIKM26WRAEASSAJKGUPTTUZ6GTLANCNFSM5NWBWGHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

ohrickster avatar Feb 07 '22 10:02 ohrickster

Just saw something very similar to this happen, for the second time now, with a chest next to a smelter with AutoDeposit and AutoFuel on. The chest and smelter hopper are both at their default size.

Both times, it happened when dropping several stacks of iron scrap. Both times I was hardly paying attention and even second guessed what I was seeing, but this time I was sure I had about 3.5 stacks of ore, and suddenly there was only a half stack of ore between the smelter's hopper and the chest. This was on my friend's server, so not sure of it's details.

We're not using any mods other than Valheim Plus.

bgoosen avatar Mar 04 '22 05:03 bgoosen

Just saw something very similar to this happen, for the second time now, with a chest next to a smelter with AutoDeposit and AutoFuel on. The chest and smelter hopper are both at their default size.

Both times, it happened when dropping several stacks of iron scrap. Both times I was hardly paying attention and even second guessed what I was seeing, but this time I was sure I had about 3.5 stacks of ore, and suddenly there was only a half stack of ore between the smelter's hopper and the chest. This was on my friend's server, so not sure of it's details.

We're not using any mods other than Valheim Plus.

Same here!

Deposited around 600 Wood in the chest next to our Kiln in order to turn it into Coal. Wood is gone, but not added up into the Kiln. So all my wood collection went to dust :(

ghost avatar Mar 07 '22 14:03 ghost

Encountered the same issue.

A full chest of meat. All is gone in Narnia and i found 4 honey in. Not the first time it append to me, in every games since i use this mod i have issues like that but i just found why (i had doubts on the auto deposit with the honey).

But i'm not sure if the honey is the source of the problem. I had a similar issue with a stack of BlackMetal who disappear for no reasons in a chest of my foundry. Sure it's relative to the auto fuel / deposit.

Reproduction case for the Honey : Nothing more than what i explain before. The chest was full and a random drop of honey replaced the contents of the chest by 4 honey.

Reproduction case for BlackMetal : i put a part of a stack with a part of an another stack in my not full chest. At the same time the auto fuel took something (in my case coal or silver) and all the new added BlackMetal disappear (not the already present one). Just to precise it's a classic foundry ofc so it can't be fuelled with BlackMetal.

So maybe it's the same bug or it's 2 differents one but there is something with the auto deposit / fuel.

Astarosa avatar Feb 15 '23 12:02 Astarosa

Looks like auto-deposit could use a refactor. Chests only allow one person to use them at a time, which likely means there is no conflict resolution on the server for multiple changes at once, and thus the latest change is accepted. Additionally, the entire contents of the chest is written at once, so if a user adds a stack of iron to the chest and the auto deposit does at the same time, whichever is accepted latest is the one that persists. So, either the new inventory with +4 honey is added, or the +30 iron, but not both. This race condition is compounded by the fact that the mod adds one item at a time and updates the server after each item. This doesn't affect most of the uses that only drop one item at a time, but honey drops 4 at a time and this number could be modified by the mod itself. This gives more opportunities for user changes to get clobbered as the window for conflicts is larger.

I've seen this work the opposite way for myself as well, I've taken a stack of iron out of a chest being deposited to and duped a stack of iron on accident.

So, a couple options off the top of my head (I haven't investigated the code too thoroughly, so these may not be feasible if I have a misunderstanding):

  • No changes
    • race conditions between auto deposit and players persist, causing items to disappear when auto-deposit happens at the same time a player interacts with a chest.
  • Allow for dropping multiple items at once into inventory
    • only really affects honey
    • lowers chances for race conditions, but they still can and will happen. So this only mitigates the issue a little.
  • Auto deposit doesn't deposit into chests the player is using.
    • Container.isInUse() and Container.setInUse() exists for this, not sure if they are feasible.
    • Possible behaviors:
      • items could be dropped in the next available chest
        • Could be confusing for players
      • items could be skipped, dropped at the next possible time
        • makes sense for honey, not sure about other single drop use cases like smelter. Would the items just be lost if they are skipped?
      • drop items to ground instead?
        • Also could be confusing for players.
  • Kick player out of chest when auto-deposit happens
    • similar functionality exists for when a player is too far away from a container, the game will kick them out.
    • Annoying to get kicked out of the chest, but is it better than losing an inventory of iron..?
    • May still be race condition-prone, will the player for sure get kicked out of the chest before they deposit items?
    • If someone sets a producer to deposit every second, this could lock people out of the chest until the producer finishes all the items it is working on.
  • Server-side conflict resolution of multiple inventory changes
    • complicated to implement, bug-prone still, likely not feasible. I believe it would require storing more data than is stored currently to track conflicting changes.

Grantapher avatar Feb 15 '23 19:02 Grantapher