botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[.Net SDK, state service] Doesn't save state

Open SenseVision opened this issue 8 years ago • 71 comments

Bot Info

  • SDK Platform: .NET
  • SDK Version: 3.14.1.1
  • Active Channels: Doesn't matter
  • Deployment Environment: Azure Tables *Microsoft.Bot.Builder.Azure : 3.2.5 *WindowsAzure.Storage : 8.7 didn't upgrade to 9+ , because of https://github.com/Microsoft/BotBuilder-Azure/issues/58

Issue Description

It started about 2 weeks ago .

Bot doesn't save it's current state \ deserialize the previous state instead of current (the last one where he stopped ).

Occurs rarely.(It could be user get this bug , it could be not , user could get this bug several times per conversation)

Occurs in random moment of the workflow (doesn't depend on which dialog is \ context.Wait(Smth) ).

No Exceptions at all ! Neither in workflow nor http requests to Azure Tables.

Bot process looks like :

Bot state is 0 Bot moves to the state 1( send message 1) Bot waiting for an answer( user message 1) // User gets bot message 1 User respond (user message 1) // Bot accept answer (user message 1) , Bot state = 1( expected = 1) Bot moves to the state 2( send message 2) Bot waiting for an answer( user message 2) // User gets bot message 2 User respond (user message 2) // Bot accept answer (user message 2) , Bot state = 1 ( expected = 2)

Actual Results

Not really good example (because use nested dialog), but same was with dialogues , wich doesn't know anything about each other.

errorstate

Later , didn't changed anything in code \ server config any elsewhere ok

SenseVision avatar Apr 16 '18 10:04 SenseVision

Please share your code, this will be next to impossible to diagnose without your code.

JasonSowers avatar Apr 16 '18 21:04 JasonSowers

@JasonSowers added as collaborator to the copy of repository

Also today we have tried to downgrade BF to 3.12.4(stable version we used before 3.13.1) right now 30+ full conversations(25-40 interactions) , no bug

SenseVision avatar Apr 17 '18 11:04 SenseVision

You're not going mad SenseVision, I just had a panic attack for most of the afternoon today because I thought I had completely messed up my work (and mediocre understanding of how BotFramework worked).

Exactly the same experience after moving from 3.14.0 to either 3.14.1 or 3.15 (not enough testing between upgrades to determine which) - random mutations in conversation position, sometimes even going back to points in 'completed' (Context.Done) dialogs. I only noticed properly after upgrading again to 3.15.

I'm using Azure Table Storage for state, and an Azure app service for the bot. Also 3.2.5 for Microsoft.Bot.Builder.Azure. Dialogs for conversations. (No LUIS, no FormFlow, or anything fancy. Bog-standard MessagesController.Post -> scope.Resolve, Conversation.SendAsync.... -> RootDialog -> context.Call(other dialogs) )

After downgrading Bot.Builder and Bot.Builder.History from 3.15 to 3.13.1 (and BotConnector to 3.14.07, although I can't say right now which is making the difference) everything is OK again. WindowsAzure.Storage is at 9.1.1.

To Jason and the team - apologies, as this kind of random comment that is missing a workable repro is about as welcome as a kick in the teeth :)

If I can find a consistent repro, I will certainly post it, but as SenseVision notes, it is frustratingly random.

oflahero avatar Apr 17 '18 22:04 oflahero

I got your invite, I will start looking into this. We recently released a new SDK version 3.15 can you please confirm if you are experiencing the same issue in 3.15. @oflahero I couldn't gather if 3.15 was working or not for you from your post.

JasonSowers avatar Apr 17 '18 23:04 JasonSowers

Small update: Bot.Connector is not the issue. It's a problem in Bot.Builder (and/or .History) between 3.13.1 (OK) and 3.15 (not OK).

I can't test if it's Bot.Builder.History in isolation as upgrading that nupkg requires Bot.Builder.

I will try 3.14.1.1 at some point tomorrow and try to narrow it down.

oflahero avatar Apr 17 '18 23:04 oflahero

I experienced the same issues with 3.14.1.1.

So the problem appears to have been introduced somewhere when moving between 3.13.1 to 3.14.1.1 in Microsoft.Bot.Builder and Microsoft.Bot.Builder.History (unless I was doing something stupid in my code that relied on something that was fixed after 3.13.1!) I don't have any further granularity info.

oflahero avatar Apr 18 '18 08:04 oflahero

@oflahero Can you please share your project as well? I'm trying to make a minimum reproducible example and want to see if there are any similarities between your project and SenseVision's

So I have started with the most simple implementation of saving state data and I am adding pieces in from SenseVision's project to try to figure out the root cause, but I haven't been able to reproduce it yet. I will be spending the day looking into this

JasonSowers avatar Apr 18 '18 17:04 JasonSowers

@oflahero @SenseVision Can either of you confirm this happens in the emulator as well? I have been trying all day to reproduce this with no luck.

JasonSowers avatar Apr 18 '18 21:04 JasonSowers

Hey there. I spent a bit of time on this today too - I've settled on 3.14.0 for Bot.Builder, Bot.Builder.History and Bot.Connector as the most stable configuration. Anything higher (>=3.14.1) and the issue is back.

I tried to reproduce in the emulator with no luck. It's only happening for me in the channel, which in my case is Facebook Messenger.

My project's commercial, and currently pretty large, so no sharing I'm afraid. I understand the frustration of spending time trying to reproduce an issue like this. I will hopefully try to do a pared-down minimal project that exhibits the problem, but I wouldn't be surprised if it doesn't. The problem project has so many interconnected moving parts - targets full 4.7.1, also NetStandard by some NuGet packages. I have enough issues with assembly bindings as it is.

I can understand putting this on hold til more people claim to have the issue also.

oflahero avatar Apr 18 '18 21:04 oflahero

Let me try facebook, no luck with repro in the emulator, webchat, (or facebook now) 👎

I would really prefer to get to the bottom of this rather than put it on hold. I would guess it is affecting more customers than just you 2. So any more help you can give would be greatly appreciated

JasonSowers avatar Apr 18 '18 21:04 JasonSowers

Crazy busy today but I'll try to do a repro later if I can.

oflahero avatar Apr 19 '18 10:04 oflahero

@JasonSowers sorry , i haven't answered , was super busy .

Check 3.15 -> the earliest i'll be able try would be on Tuesday, i guess.

Can either of you confirm this happens in the emulator as well? -> 3.14.1.1 - yes . Emulator and FB.

I've rechecked references history , looks like @oflahero is right 3.13.1 is OK

SenseVision avatar Apr 20 '18 05:04 SenseVision

Hi guys, we experienced the same thing after upgrading from 3.13 to 3.14.1.1. dialogs seem to jump to a previous state. Seemed to be most reliably reproducible in the web versions of Slack and MS Teams (not sure if that has anything to do with it though)

Our guess was that something in the way the bot state is saved has changed between those versions (we are using TableStorage with a custom key for the bot state), but we couldn't find anything suspicious in the Bot.Builder commits...

So we just reverted back to 3.13.1 and everything works again. Would be nice to get this out of the way so we can upgrade again.

thschuetze avatar Apr 20 '18 13:04 thschuetze

Welcome to the club!

I'm about halfway through setting up a minimal project - haven't forgotten about you Jason. No guarantees it'll exhibit the symptoms, mind.

oflahero avatar Apr 20 '18 16:04 oflahero

No worries guys, been busy over here as well. I hope to make some more time to try to get to the bottom of this next week. All of my bots are running 3.15 (because I test the SDK before we release it) and I have not noticed any issues with state like you are seeing, so I'm hoping one of you can provide a clue here especially because I haven't been able to reproduce this.

JasonSowers avatar Apr 20 '18 23:04 JasonSowers

I have a repo at https://github.com/oflahero/315Issue where it looks like I can reproduce the issue.

It's a simple bot that echoes what you type with the length of the input string. If you enter 'find', it also launches a dialog simulating searching for a phone or email contact by name substring.

There are only three contacts hardcoded. Once it either returns a match or tells you there are no matches, you're out of the dialog again.

Using branch 315 (Bot Builder & Connector at 3.15.0), and the Facebook channel, you can eventually (after repeatedly hitting 'find' and responding appropriately) observe it jump out of sync. It may take a good ten minutes of this.

Note: there's some code in the repo that isn't used - I was just trying to grab stuff from the problem project in order to reproduce the issue.

I have a publicly available FB messenger page hosting the 3.15.0 version, if anyone wants to try it without installing themselves. Just send me your FB profile identifier so I can add you as a test user to the app on FB Developer, and I'll let you know where to look.

Branch 314 is the stable (3.14.0) version.

The 'UnrelatedPostIssue' branch is another problem entirely - it's a one-character diff commit, but it causes a 'BadRequest' exception in the bot on PostAsync. It's completely floored me.

oflahero avatar Apr 22 '18 00:04 oflahero

Hi Guys I have also noticed that our dialogs are jumping to a previous state ever since I updgraded the bot builder sdk from 3.13.1 to 3.15.0. It appears to specifically occur when there is a delay in the user response. We are storing our state using local SQL TableStorage. I have first noticed this via the directline channel. It also occurs in the emulator.

seca23 avatar Apr 23 '18 09:04 seca23

I went through the Bot.Builder commits between 3.13.1 and 3.14.1.1

The only change related to our issue seems to be CachingBotDataStore changes in commit https://github.com/Microsoft/BotBuilder/commit/992e29f4e0f61b98b31557fdba68d53fb8caabfc (the cache was changed from local Dictionary to MemoryCache)

I couldn't spot anything suspicious with the changes, but @oflahero could you register your TableBotDataStore directly as IBotDataStore and remove the CachingBotDataStore registration in your example and see if that helps?

thschuetze avatar Apr 23 '18 16:04 thschuetze

As I understand it though @thschuetze , you need a CachingBotDataStore sitting on top of your keyed registration for it to work though? At least until we get BotBuilder v4... (see issue https://github.com/Microsoft/BotBuilder/issues/4376)

Maybe there's a simpler way. I'll be the first to admit that the tight integration of Autofac into BotBuilder is a pet hate of mine (mainly because it confuses the hell out of me, and I loathe DI on principle :) )

oflahero avatar Apr 23 '18 21:04 oflahero

Awesome work guys, thanks for helping us work this out. I will be spending time on this today, but mainly tomorrow since its late in the day now trying to address the issue.

As a note when I spent nearly a whole day trying to reproduce I tried both with and without CachingBotDataStore and was unsuccessful.

@seca23 this issue does not seem related can you please open a new issue with details about what you are experiencing.

JasonSowers avatar Apr 23 '18 22:04 JasonSowers