fix - sso login issue for new users and stats missing issue - #460
LalitDeore wants to merge 3 commits into
Conversation
|
"Store daily_statistics as a JSON string in Datastore instead of mapping it directly to the DailyStatistics struct. This prevents issues when different backend versions have different fields in the struct and ensures stats are preserved during deployments." This specifically is really bad, especially since we actually use these stats quite frequently. About 40% of our current CPU usage is literally JSON unmarshalling right now. And that's kind of something I don't want to exacerbate. Field not mapping is not a "lets change the type" problem. It's a problem of keeping the same between backend problem. And it only occurs if you REMOVE a field in a struct array. Adding fields doesnt matter. |
I need to look into the JSON unmarshalling issue. We lose daily_statistics not only when we remove a field from it, but also when we add a new field to daily_statistics. I tested this by adding a field directly to daily_statistics in the DB for an org, and after running a workflow, it reset the daily_statistics for that org. PS: I am making this PR a draft to try another fix instead of JSON unmarshalling. I have raised a separate PR for the SSO issue so we can push it early :) |
No. Struct JSON mapping does not fail when you have a new field. If so, please create a test program proving it, because that entirely goes against how structs work. PS: If you want it to be a string, how do you intend to make it indexable? You need to think about this architecturally, for long-term use. And known data types should never go into strings/bytes. Unknown data is the only option, and even then, we "want" to use maps or interfaces (where possible). |
|
bump |
Issues:
daily_statisticsandonprem_statsare loaded from Datastore. When a new field is added to the daily_statistics struct and the main backend is deployed before another backend, the older backend fail to loaddaily_statistics. On the next stats update, this resetdaily_statisticsand cause the organization to lose its stats.Fixes:
daily_statisticsas a JSON string in Datastore instead of mapping it directly to theDailyStatisticsstruct. This prevents issues when different backend versions have different fields in the struct and ensures stats are preserved during deployments.