Sorry, something went wrong.
|
Reviewing the devin analysis |
Sorry, something went wrong.
There was a problem hiding this comment.
one small nit but otherwise this lgtm
Sorry, something went wrong.
|
@franciscojavierarceo -Thanks for the feedback on leaving the async version - updated. Feel free to merge, good to go. |
Sorry, something went wrong.
| ) | ||
|
|
||
| # Process each entity update | ||
| for entity_key, features, timestamp, _ in _latest_data_to_write(data): |
There was a problem hiding this comment.
🔴 Using _latest_data_to_write discards multiple list updates for the same entity in a batch
The update_online_store and update_online_store_async methods use _latest_data_to_write(data) to iterate over data, which deduplicates records by keeping only the latest record per entity key.
Click to expandThe _latest_data_to_write function at dynamodb.py:1166-1173 is designed to keep only the record with the latest timestamp for each entity:
This is correct for normal writes (where you want to overwrite with the latest value), but incorrect for list append/prepend operations.
If a user tries to append multiple items to the same entity's list in a single batch call, only the item with the latest timestamp will actually be appended. For example:
Only ["tx3"] will be appended because _latest_data_to_write discards the first two records.
Recommendation: For list update operations, process all records in order without deduplication. Either remove the _latest_data_to_write call in update_online_store/update_online_store_async methods, or create a new iteration function that preserves all records while still sorting by timestamp to ensure correct ordering of appends.
Was this helpful? React with 👍 or 👎 to provide feedback.
Sorry, something went wrong.
Summary
Adds DynamoDB-specific list update functionality to avoid inefficient read-modify-write patterns for array-based features. This implements the solution requested in #5687.
Fixes #5687
Changes
Testing
Usage Example