Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unknown type: Decimal('value') error #1874

Merged
merged 2 commits into from Feb 21, 2022
Merged

Fix Unknown type: Decimal('value') error #1874

merged 2 commits into from Feb 21, 2022

Conversation

amCap1712
Copy link
Member

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.

Copy link
Member

@mayhem mayhem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down and how it happened. Well done and thanks!

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.
@amCap1712 amCap1712 merged commit 7abda90 into master Feb 21, 2022
@amCap1712 amCap1712 deleted the fix-index-count branch February 21, 2022 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants