Forum OpenACS Q&A: Invalid command name "::thread::create", invoked from within ns_mutex eval ns_mutex::throttle

Hello!

I've gotten stuck with yet another error. I am running OpenACS directly from CVS and I recently ran cvs update -Pd. I am reaching the following error when I'm trying to reach my site.

invalid command name "::thread::create"
while executing
"::thread::create"
invoked from within
"ns_mutex eval ns_mutex::throttle {
#my check_blueprint
#my log "after lock"
if {![nsv_exists [self class] [self]]} {
if {[:l..."
("uplevel" body line 1)
invoked from within
"uplevel [list ns_mutex eval $mutex $script]"
(procedure "ad_mutex_eval" line 2)
invoked from within
"ad_mutex_eval ${:mutex} {
#my check_blueprint
#my log "after lock"
if {![nsv_exists [self class] [self]]} {
if {[:lightweigh..."
(procedure "do" line 5)
invoked from within
"::throttle do throttler add_url_stat GET /resources/dotlrn/dotlrn-toolbar.css {accepttime 0.000093 queuetime 0.000100 filtertime 0.062357 runtime 0.00..."
::throttle->add_url_stat
invoked from within
":add_url_stat ${:method} ${:url} [:partialtimes] ${:requestor} ${:pa} [ns_set get [ns_conn outputheaders] Content-Type]"
(procedure "trace" line 9)
invoked from within
"throttle trace"
(context: filter proc)

invoked from within
"throttle trace"

Dear Ann,

apparently, your installation lacks Tcl thread support https://www.tcl.tk/man/tcl/ThreadCmd/thread.htm

When one installs Naviserver from installation script here https://raw.githubusercontent.com/gustafn/install-ns/master/install-ns.sh, thread support should be compiled and enabled in your tcl installation via the --enable-threads configuration flag.

Just a wild guess: can it be that a different tcl version was installed e.g. via the package manager that is lacking thread support and this is overriding the compiled one? I would also check the log file at startup for possible hints.

Ciao

Antonio

Some more specific suggestion: check the configuration file of your OpenACS instance for "libthread". You should fine a few lines where Naviserver checks at startup whether the library is there or not and outputs a log statement.

Look for such log statement in your startup log file and you should find whether libthread is there or not.

Hope this helps

Antonio

Hello!
We added a package require Thread to xotcl-core/tcl/40-thread-mods-procs.tcl and the error message changed to

invalid command name "throttler"
while executing
"throttler add_url_stat GET /resources/theme-zen/css/handheld.css {accepttime 0.000000 queuetime 0.000059 filtertime 0.008928 runtime 0.000018 ms 9} no..."
invoked from within
"thread::send $tid $args"
(procedure "do" line 62)
invoked from within
"::throttle do throttler add_url_stat GET /resources/theme-zen/css/handheld.css {accepttime 0.000000 queuetime 0.000059 filtertime 0.008928 runtime 0.0..."
::throttle->add_url_stat
invoked from within
":add_url_stat ${:method} ${:url} [:partialtimes] ${:requestor} ${:pa} [ns_set get [ns_conn outputheaders] Content-Type]"
(procedure "trace" line 9)
invoked from within
"throttle trace"

I am using the tclsh for Arch Linux, which is thread enabled.

Additionally tcl_platform(threaded) = 1
Dear Ann,

throttler is a special thread which is created at load time by xotcl-request-monitor. For this to happen, thread support should be there at that specific point in time (e.g. loading of xotcl-request-monitor tcl files at startup).

I would suggest against hacking the Thread library in this or that file. Instead, please try to find the root cause of your issue: most likely and for reasons still unknown, Naviserver is not finding the thread library at startup.

As suggested before, the config file of your instance and the log file should give you the elements to find out what is going on.

Ciao

Antonio

Ann mentioned to have added a "package require Thread"... which is not the way to go. My guess is that she took the thread library, which is a the result of a off-the-shelf Tcl installation, and loaded this this way - leading to the broken behavior.

The problem here is, that libthread can be compiled as a tcl package or as a AOLserver/Naviserver module. The latter is required here. In order to compile libthread as AOLserver/NaviServer module, it has to be configured with "--with-naviserver=..." and then loaded as a module (see e.g. [1]).

But of course, the easiest approach is get it via install-ns [2], which does this for you. Maybe Ann has done this, and was brought to the wrong track by the 2-server config file, which was stripped down from the classical sample config files doing already the right thing.

i will update the wiki page concerning libthread....

all the best
-g

[1] https://bitbucket.org/naviserver/naviserver/src/70aaa5cfbd474b3b94a9a98e868f1e42e23861fd/openacs-config.tcl#lines-752
[2] https://openacs.org/xowiki/naviserver-openacs

Hello!

We solved the problem by pointing in the configuration to the libthread2.8.2.so that was distributed with the Arch Linux AUR package.

Later I will compile Tcl and libthread with the naviserver option.