@@ -192,7 +192,7 @@ func (s *SQLite3Store) MarkSessionPreparedWithRequest(ctx context.Context, req *
192192 return tx .Commit ()
193193}
194194
195- func (s * SQLite3Store ) MarkSessionDone (ctx context.Context , sessionId string ) error {
195+ func (s * SQLite3Store ) MarkSessionDone (ctx context.Context , sessionId string , callId string ) error {
196196 s .mutex .Lock ()
197197 defer s .mutex .Unlock ()
198198
@@ -202,12 +202,21 @@ func (s *SQLite3Store) MarkSessionDone(ctx context.Context, sessionId string) er
202202 }
203203 defer common .Rollback (tx )
204204
205+ now := time .Now ().UTC ()
205206 err = s .execOne (ctx , tx , "UPDATE sessions SET state=?, updated_at=? WHERE session_id=? AND state=?" ,
206- common .RequestStateDone , time . Now (). UTC () , sessionId , common .RequestStatePending )
207+ common .RequestStateDone , now , sessionId , common .RequestStatePending )
207208 if err != nil {
208209 return fmt .Errorf ("SQLite3Store UPDATE sessions %v" , err )
209210 }
210211
212+ if callId != "" {
213+ _ , err = tx .ExecContext (ctx , "UPDATE sessions SET state=?, updated_at=? WHERE session_id!=? AND state=? AND request_id=?" ,
214+ common .RequestStateFailed , now , sessionId , common .RequestStatePending , callId )
215+ if err != nil {
216+ return fmt .Errorf ("SQLite3Store UPDATE sessions %v" , err )
217+ }
218+ }
219+
211220 return tx .Commit ()
212221}
213222
0 commit comments