fix: Remove excessive db call to update state table.

PiperOrigin-RevId: 764375522
This commit is contained in:
Shangjie Chen 2025-05-28 12:45:41 -07:00 committed by Copybara-Service
parent 3611e9fe09
commit d83ee1a6f2

View File

@ -11,6 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import annotations
import copy import copy
from datetime import datetime from datetime import datetime
import json import json
@ -512,15 +514,16 @@ class DatabaseSessionService(BaseSessionService):
_extract_state_delta(event.actions.state_delta) _extract_state_delta(event.actions.state_delta)
) )
# Merge state # Merge state and update storage
app_state.update(app_state_delta) if app_state_delta:
user_state.update(user_state_delta) app_state.update(app_state_delta)
session_state.update(session_state_delta) storage_app_state.state = app_state
if user_state_delta:
# Update storage user_state.update(user_state_delta)
storage_app_state.state = app_state storage_user_state.state = user_state
storage_user_state.state = user_state if session_state_delta:
storage_session.state = session_state session_state.update(session_state_delta)
storage_session.state = session_state
storage_event = StorageEvent( storage_event = StorageEvent(
id=event.id, id=event.id,