Detect FeatureCompatibilityVersion by inspecting database file(s)?

Does anyone know if it’s possible to detect the featureCompatibilityVersion of a database simply by looking at a file within the data directory? I would like to be able to (programmatically) inspect a mongo data folder and determine the correct mongod binary to use.

I do not have any mongod with which to open the database - I’d be pulling down a version appropriate for the existing database.

Hi @Nick_Judson, welcome back to the community! :wave:

In the past I have used the wt tool to dump out the data from the binary files stored on your system. I’ve followed along with this Percona blog post series. I don’t remember building from source so I probably pulled it down from GitHub. I would recommend making a copy of the files that you’re working with “just in case”.

I have however just found PyWT which is written by @kevinadi (a MongoDB employee and regular here on the community). This makes things much easier to work with as you don’t have to remember long Linux pipelines to get the data. :wink: Note however that this tool has not been worked on in 5 years so there is no guarantee of usability or future compatibility should things change in the future. I will let Kevin address if this tool is safe to use or not, but it does seem to work on data files created by MongoDB 6.0.

Here are the commands that I ran against a newly started database (no user data added), and I was able to get the data that you are interested in.

python3 PyWT.py --dbpath /path/to/data/files --list
python3 PyWT.py --dbpath /path/to/data/files --table collection-value-from-above --pretty

Just replace with your data path and collection name.

Here’s a screenshot showing the results:

5 Likes

Thanks for the reply Doug. I’ll spend some time trying to figure out how it all goes together.