Description
Issue Description
In SchemaCache, there is the function setOneSchema for setting individual schemas of classes in the cache. this function is never utilized and there is never individual schemas accumulating in the cache.
however, getOneSchema is being used and it always results in one miss before the MAIN_SCHEMA is looked up for that class, because the schema for that class would never have been set before.
Steps to reproduce
- set enableSingleSchemaCache to true (same could happen without this option set to true, but my setup is like this)
- use Redis adapter for easier investigation, or console.log()'s for the LRU cache might work as well. if used redis, use redis-cli with monitor option to check real-time logs
- send some requests from the client quickly (because there are ttl's for keys :) ) to make schema caching and lookup work, and produce some logs.
- check redis-cli or default console.log()'s for caching logs.
Expected Results
After a lookup for one class misses, schema info related to that class would be inserted to the cache so that consecutive lookups won't miss.
Actual Outcome
no inserts regarding single class schemas are done, however lookups are still being done, resulting in many misses and useless round trips.
Environment Setup
- Server
- parse-server version (Be specific! Don't say 'latest'.) : 2.6.5
- Operating System: Amazon Linux
- Hardware: t2.nano (512 MB RAM, 1 CPU, EBS Storage)
- Localhost or remote server? : AWS
Logs/Trace
Following is some logs from redis-cli, I traced these logs for minutes and no sets (psetex) are done for individual schemas
1517286114.528181 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.529996 [] "get" "xxbackend:__SCHEMAPhoto"
1517286114.530845 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.790274 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.791514 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.794785 [] "get" "xxbackend:__SCHEMAPost"
1517286114.795592 [] "get" "xxbackend:__SCHEMALike"
1517286114.796424 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.797531 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.801867 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.803162 [] "get" "xxbackend:__SCHEMAPost"
1517286114.804042 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.806571 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.808008 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.809425 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.811327 [] "get" "xxbackend:__SCHEMAPost"
1517286114.812166 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.817408 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.818600 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.819734 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.820944 [] "get" "xxbackend:__SCHEMAPost"
1517286114.821744 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.822866 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.824021 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.825780 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.826933 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.828031 [] "get" "xxbackend:__SCHEMAView"
1517286114.828851 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.829946 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
1517286114.831018 [] "get" "xxbackend:__SCHEMAPost"
1517286114.831819 [] "get" "xxbackend:__SCHEMA__MAIN_SCHEMA"
Suggested solution
Either SchemaCache should not do lookups for individual classes and directly request main schema, or after missed lookups of individual class schemas, inserts should be done.