Repository navigation
fix: keep integers beyond 64 bits exact in SqliteSessionService state - #7586
Closed
Mahir-Puri wants to merge 1 commit into
Closed
Mahir-Puri wants to merge 1 commit into
Mahir-Puri wants to merge 1 commit into
Conversation
SQLite reads an integer outside the signed 64-bit range as a REAL, so the state merge turned values like 0xFEDCBA9876543210 into floats. Rebuild those keys from the original JSON text (via ->) instead of the parsed value, and bind the session delta by number since it is now used more than once in the statement. Fixes google#7576
|
@Mahir-Puri this is #7577 again. I opened #7576 and #7577 a day before this one: same example hash ( Using an AI agent is fine, I use one too. But it shouldn't take someone's open PR and send it back as a new one. Please close this in favor of #7577. It also still has the bug BichengWang found in #7577: the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
SqliteSessionServicemerges state deltas inside SQLite (_MERGE_STATE_SQL).SQLite reads an integer outside the signed 64-bit range as a REAL, so a value
like
0xFEDCBA9876543210came back as1.8364758544493064e+19(a float). Thisalso happened when a later turn wrote an unrelated key, because the merge
rebuilds every key in the row. The in-memory and database services keep the
value exact.
Solution:
integerbut whose parsed value is aREAL is rebuilt from its original JSON text (using the
->operator) insteadof the parsed value. The float handling from fix(sessions): keep SQLite session state numbers exact across updates #7426 is unchanged.
?1to?5), sincethe delta is used more than once in the statement.
Note: the
->operator needs SQLite 3.38 or newer.Testing Plan
Unit Tests:
Added a 64-bit
fingerprintvalue to_EXACT_NUMBERSintests/unittests/sessions/test_session_service.py. It covers session,user:and
app:state, both for new writes and after an unrelated state delta.Without the fix, 6 of the SQLite cases fail.
pytest tests/unittests/sessions: 604 passed.pytest tests/unittests(macOS, Python 3.11): 20049 passed, 1 failed. Thefailure is
test_reading_directory_raisesintests/unittests/integrations/vmaas/test_agent_engine_environment.py. Itfails the same way on unmodified
main, so it is unrelated to this change.Manual End-to-End (E2E) Tests:
Ran the reproduction script from #7576 (fake model,
SqliteSessionService)with
PYTHONPATH=src python repro.py:Checklist