Fix Unknown type: Decimal('value') error #1874
Merged
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.
I was looking into LB-463 and checking why the count was still inaccurate since we moved to the database. Turns out we had an old key set without expiry for total listen count. I deleted it from redis so that a new would be calculated. However, it errored out as follows:
The SUM() function in postgres returns a DECIMAL value even if summing int columns. So psycopg2 returns the
value
as a DECIMAL type which is not recognized by msgpack/redis. This causes Unknown type: Decimal() error when trying to put the value in cache. To fix, cast the value to an int in python. Tested this fix on beta.lb.So, I set the count manually in redis without an expiry key. Once the fix is merged, we need to remove the without expiry key so that total listen counts are recalculated on a regular basis.