Forum OpenACS Q&A: Issues with ns_cache emulation in Naviserver 4.99.6?

We think we have noticed some issues with the ns_cache emulation in Naviserver 4.99.6 since switching to it a couple of months ago. (Our Xotcl is 1.6.8.)

In one particular case, calls to fs::add_file from the file storage upload page resulted in an “expected boolean but got “”” error. The error was occurring at the reference to content::type::content_type_p. When looking at that proc in the CR, I noticed that content::type::content_type_p_not_cached should never return “”.

We had some other, similar page errors where util_memoize was involved as well. After inserting some log statements in util_memoize, I noticed that “ns_cache get" was returning 1 but the “pair” reference passed in to the proc (ns_cache get util_memoize $script pair) which should contain the data and cache time was not populated.

I haven’t been able to determine if there’s a pattern wrt the cache keys that have been troublesome and, so far at least, this doesn’t seem to be a widespread issue. Nevertheless, we’d like to figure out what’s going on. Anyone else run into this?

Dear Michael,

OpenACS runs since a long time NaviServer, and does not see this problem.

From your wording i would assume that you are running a rather old version of acs-core (and therefore file-storage). NaviServer does not require the classical AOLserver hack for cache expiration, since NaviServer's nscache has expiration already built in [1]. Therefore there is no need to add pairs of (value, timestamp) to the cache, to fetch the value, compare the timestamp, refetch and store if necessary. This old policy is also prone to race conditions; when two cache operations happen on the same entry at the same time, confusion is likely. With NaviServer one needs just a single, atomic operation, the remainder happens in C. Therefore, the memoize-procs [2] are quite differently implemented for AOLserver and NaviServer in recent versions of OpenACS.

Also, something else comes to my mind: there were many places in OpenACS, where util_memoize was called with double quotes ("...") instead of a proper lost ([list ...]). In such cases, it was just a matter of luck, when a argument confusion happened. All these places are fixed in the oacs-5-8 branch.

all the best
-g

[1] http://naviserver.sourceforge.net/n/naviserver/files/ns_cache.html
[2] https://github.com/openacs/openacs-core/blob/oacs-5-8/packages/acs-tcl/tcl/memoize-procs.tcl

Thanks for the response, Gustaf. You're right - we're currently running 5.7. I didn't realize that you had retooled memorize in the toolkit for 5.8 as well.

We should be upgrading soon. Good to know that should take care of this.

Thanks again.