Mongod keeps quitting on mac running Big Sur

I have a mac running the latest version of Big Sur. I installed mongodb-community using homebrew, and it has been working ok for a week or so. All of a sudden, I find that mongod keeps quitting. I’ve tried uninstall mongodb-community and re installing it, but the same thing happens. When I run brew services list, it indicates that it’s an error. Could the database have been damaged? Are there tools that can check that? I was using it during a long run yesterday using the python package sacred, which records the results of experiments in a mongo database. I have trace backs, and logs. I don’t see a way to attach them to my post, if that would be helpful.

A followup: I did a mongod --repair. Unfortunately, even though it was running with journaling, it said that the repair failed. Is there any way to at least get back some of the data? In any case, how do I get mongo to start working again? If I move all of the database files to another directory, will mongo recreate new files in an empty directory?

So, I blew away the files (after copying them) in the directory /usr/local/var/mongdb and restarted mongod with brew services start mongod. Things seemed to be ok for quite a while. I’ve had a long running job using the python package sacred which writes to the mongo database. Just now I got a notice that mongod quit. Below is the trace back. Any idea what could be wrong?

Here’s the beginning of the report from the system:

Process: mongod [96082]
Path: /usr/local/Cellar/mongodb-community/4.4.4/bin/mongod
Identifier: mongod
Version: 0
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: mongod [96082]
User ID: 501

Date/Time: 2021-04-22 18:17:06.676 -0400
OS Version: macOS 11.2.3 (20D91)
Report Version: 12
Anonymous UUID: 4556CAA5-CE53-CD6B-2E13-8E5DB5751AF1

Sleep/Wake UUID: D3D30E4E-51D4-46D7-B536-DA2E49542AAE

Time Awake Since Boot: 47000 seconds
Time Since Wake: 38000 seconds

System Integrity Protection: enabled

Crashed Thread: 14 WTJournalFlusher

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called

Now I’ve been able to restart mongod, but looking at the logs it says about port 27017 “socket already in use”.

Itt means another mongod already running on port 27017
You can check by ps -ef|grep mongod

How did you start your mongod
From services or from command line?

Before starting mongod just run mongo
If you are able to connect means a mongod is running on default port 27017

Thanks. I tried ps -ef | egrep mongod – no hits. I start it via brew services. brew services list said that nothing was running. When I ran mongo it said that nothing was running. Eventually I rebooted (I needed to do that anyway) and I was then able to start things ok. I don’t know why this keeps happening.

My problems bring up another question. What are the best practices for backing up the database. Since it looks like mongo is fragile enough for an error to corrupt the database so that it can’t be repaired (this happened to me), what do people do to backup the current state?

Hi @Victor_Miller welcome to the community!

For details on using brew to install MongoDB, please see Install MongoDB Community Edition on macOS. The page includes the list of important files that may be useful.

Any data corruption issue is a serious issue, so if you don’t mind, please open a ticket in the SERVER project describing what you experienced in detail, along with reproduction steps.

Regarding best practices in backup, it’s more of a case-by-case basis and what you need. Personally I do a database dump using mongodump for my local (development) instance once in a while, and I also use Atlas free tier as another data store that I sync with my local instance reasonably frequently. My Atlas use is so that my data is available even if I accidentally spill coffee on my laptop :slight_smile:

Best regards
Kevin