Memory issues on Jobe server (mongosh)

Memory issues on Jobe server (mongosh)

by Mark Stern -
Number of replies: 6

I am trying to create a question type for MongoDB (queries only using mongosh connecting to a static database). When I try to connect, I get the following error:

***Run error***
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Traceback (most recent call last):
  File "__tester__.python3", line 40, in <module>
    output = subprocess.check_output(['mongosh', "commands.js"],
  File "/usr/lib/python3.10/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['mongosh', 'commands.js']' died with <Signals.SIGABRT: 6>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "__tester__.python3", line 45, in <module>
    raise Exception("mongodb error: " + str(e))
Exception: mongodb error: Command '['mongosh', 'commands.js']' died with <Signals.SIGABRT: 6>.
This might mean I do not have enough memory on my Jobe server (it has 1GByte), but I can run mongosh on the jobe server and connect to the database without any problem.

Any other thoughts?

Thanks,

Mark Stern


In reply to Mark Stern

Re: Memory issues on Jobe server (mongosh)

by Richard Lobb -
You probably just have to increase the memory limit that's used on the Jobe server. You do that in the question. Or you can do it in the question type if you've made a special type for mongosh questions. See this thread for instructions: https://coderunner.org.nz/mod/forum/discuss.php?d=141. You could first try setting the memory limit to 0 (which disables memory limit checking) then expore a bit to find a realistic value. 1000 perhaps?
In reply to Richard Lobb

Re: Memory issues on Jobe server (mongosh)

by Mark Stern -
Thanks, that worked. 1000 was not enough, but 1500 did the trick.
In reply to Mark Stern

Re: Memory issues on Jobe server (mongosh)

by Mark Stern -
This has come back to haunt me. I upgraded the Jobe Server (to Ubuntu 24.04), and the version of mongosh. The above error returned. So I increased the memory limit to 1600. I then got:

***Time limit exceeded***

So I increased TimeLimit to 15. When I did this, Moodle threw me out with a 404 error. This MAY be an issue with our Moodle configuration/set-up, but our technical support could not find anything suspicious in the logs. Is there anything else I can try?

Thanks,

Mark Stern
In reply to Mark Stern

Re: Memory issues on Jobe server (mongosh)

by Richard Lobb -
The time limit error is likely spurious - I've seen such errors result from the memory limit being too low. Possibly the system is looping trying to allocate memory.

404 errors occur if file uploads to jobe fail. Dioes the question or its prototype have support files? It's possible that the 404 is also a memory limit issue though I haven't seen that before.

Certainly the first thing to try is setting the memory limit to 0, just for testing purposes. Then, if 404s persist, confirm that it's a file upload problem by running a question without support files.

File uploads will fail if Moodle security settings or network components like firewalls are disallowing HTTP PUT requests.
In reply to Richard Lobb

Re: Memory issues on Jobe server (mongosh)

by Mark Stern -
Thanks. Setting the memory limit to 0 did not help, and there are no support files. I do not know what the problem was, but it is moot.

The new version of mongosh lets me specify a file as input, and it then behaves very differently than in interactive mode. So I re-wrote the template taking advantage of this. I also had to tweak the tests to work with the new template. It is now a lot simpler and it works.
In reply to Mark Stern

Re: Memory issues on Jobe server (mongosh)

by Richard Lobb -
Good to know. Well done on beating it into submission.