The Ctx Cache is unnecessary and brings the following issue:
Increase memory usage
Interfere with CCache
Reviewing the code, there are other classes defining an own context, like
Others to review, but maybe are valid:
And these (maybe the server is not up and because of that context cannot be used)?
Which would be a valid case to create a context, I guess maybe in Scheduler that we want to allow running with a tenant context instead of System.
A background process, can define its own context but that should be through the ServerContext.setCurrentInstance(Properties) method, not by passing a plain Properties object around. After the setCurrentInstance call, Env.getCtx() should be use after that.
The following needs fixing:
MSystem () - should be removed
MRelationType.parseWhereClause is fine as the context is only use for variable parsing and not for interaction with db or cache.
The rest is fine as it is using the ServerContext.setCurrentInstance approach.