Skip to content

MongoDB and Meteor upgrades#3745

Merged
ocdtrekkie merged 16 commits into
sandstorm-io:devfrom
mnutt:mongo-upgrade-clean
Mar 27, 2026
Merged

MongoDB and Meteor upgrades#3745
ocdtrekkie merged 16 commits into
sandstorm-io:devfrom
mnutt:mongo-upgrade-clean

Conversation

@mnutt

@mnutt mnutt commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

This has a ways to go to get ready for any sort of release, but I wanted to put it out there for discussion.

For anyone looking at the code, the interesting parts are:

I wouldn't throw it straight into production before more testing. But if you would like to try it yourself:

sandstorm stop
sandstorm update sandstorm-0.tar.xz
sandstorm migrate-mongo
sandstorm start

If you later feel like rolling back:

sandstorm stop
sandstorm rollback-mongo
sandstorm update 309
sandstorm start

Comment thread .github/workflows/build.yml Outdated
Comment thread shell/tsconfig.json Outdated
Comment thread src/sandstorm/run-bundle.c++ Outdated
@xet7

xet7 commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Can this migrate WeKan MongoDB also to MongoDB 7 ?

@ocdtrekkie

Copy link
Copy Markdown
Collaborator

@xet7 It's likely a similar sort of script could be built for apps, but this might actually be a bad idea. MongoDB apparently has a minimum opLog file size of 990 MB now, which would make each Wekan grain enormous. (Our MongoDB 2.6 install had a 16 MB opLog file.) Sandstorm servers taking an extra gigabyte of space wouldn't be a huge blocker, but I think individual grains taking an extra gigabyte of space would be a big problem.

mnutt added 5 commits February 5, 2026 17:21
- Upgrade Meteor from 2.3.5 to 2.16
- Add findAndModify polyfill for MongoDB driver 4.x (replaces fongandrew:find-and-modify)
- Update aggregate() calls to use cursor API (no callback)
- Replace bignum package with native BigInt for IPv6 handling
- Add skipLibCheck to tsconfig.json
- Update meteor-testapp to Meteor 2.16
Add infrastructure to migrate Sandstorm from MongoDB 2.6 to MongoDB 7.0:

- Bundle MongoDB 7.0, mongosh, and database tools alongside MongoDB 2.6
- Add version detection via /var/mongo/version file
- Add 'sandstorm migrate-mongo' command to migrate database
- Add 'sandstorm rollback-mongo' command to revert if issues occur
- Migration exports data with mongodump, reinitializes with MongoDB 7,
  imports with mongorestore, and sets up replica set for oplog tailing
- Upgrade Nightwatch from 0.9 to 2.6 with native ChromeDriver support
- Replace selenium-standalone with chromedriver npm package
- Update nightwatch.json for WebDriver protocol and headless Chrome
- Configure tests to use MongoDB 7 for fresh installs
- Fix async test patterns (Meteor.logout, file uploads, download handling)
- Improve loginDevAccount reliability with Meteor connection checks
- Update unit tests to use async/await
- Update Chrome version from 114 to 142 for test compatibility
- update lint problem count
@mnutt
mnutt force-pushed the mongo-upgrade-clean branch from 411cc97 to 0ecacee Compare February 5, 2026 22:25
@mnutt
mnutt requested a review from ocdtrekkie February 5, 2026 22:26
@ocdtrekkie

Copy link
Copy Markdown
Collaborator

@troyjfarrell @orblivion Tag for review, note that run-bundle.c++ gets minimized in diff view, but it's where most of the magic is.

@mnutt
mnutt marked this pull request as ready for review February 14, 2026 16:18
@ocdtrekkie ocdtrekkie added sandstorm-dev Issues hacking on Sandstorm install-config Installation/configuration issues ready-for-review We think this is ready for review labels Feb 14, 2026
@Michael-S

Michael-S commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

mongo-migration.log
I tried it with my install, this was the the end of the output:

** Stopping old MongoDB...
** Backing up old data directory...
** Starting MongoDB 7.0...
** Initializing replica set...
{ ok: 1 }
** Waiting for replica set election...
** Creating database user...
MongoServerError: not primary
** Migration failed! Rolling back...
** Check <sandstorm-install>/var/log/mongo-migration.log for details.
** Rollback complete. Original data restored.
*** Uncaught exception ***
sandstorm/util.c++:721: failed: expected exitCode == 0 [1 == 0]; child process failed; name = ; exitCode = 1
stack: 4096b1 639255 654394 653b1c 495cb6 4960f9

Edit: I don't think my mongo-migration.log has anything security-related, so I've attached it.
Edit 2: Now I attached it. The first time, attachment failed because I forgot to chown it.

@orblivion

Copy link
Copy Markdown
Contributor

If you later feel like rolling back:
...
sandstorm update 309

Shouldn't this be 308?

Comment thread make-bundle.sh Outdated
Comment thread make-bundle.sh Outdated
@mnutt

mnutt commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

d00d487 adds what I think may be a bit better way to wait until mongo is ready. If that doesn't work reliably I think we should consider just adding some timed wait.

@ocdtrekkie

Copy link
Copy Markdown
Collaborator

@Michael-S Are you in a position to see if the latest commit resolves your issue?

@Michael-S

Copy link
Copy Markdown
Contributor

@Michael-S Are you in a position to see if the latest commit resolves your issue?

I'll try it, I should be able to report back within a few days.

@Michael-S

Michael-S commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

It worked without errors this time, thank you! 🎉

Screenshot_20260307_181550

EDIT: I don't know how representative my timeout problem was for medium size or larger Sandstorm installs. My sandstorm server has /opt/ mounted on 7200RPM HDDs in RAID 1, with /opt/sandstorm about 230GB. I have 140 Grains. sudo find /opt/sandstorm -type f | wc -l gives 400,000 files total.

@troyjfarrell troyjfarrell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really pleased that you've taken on this task. The code looks good, insofar as I'm qualified to review it.

Comment thread src/sandstorm/run-bundle.c++ Outdated
Comment thread src/sandstorm/run-bundle.c++
Comment thread src/sandstorm/run-bundle.c++
Comment thread src/sandstorm/run-bundle.c++ Outdated
KJ_SYSCALL(execl(binary.cStr(), binary.cStr(),
"--bind_ip", "127.0.0.1", "--port", portStr.cStr(),
"--dbpath", dbpath.cStr(),
"--replSet", "ssrs", "--oplogSize", "16",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that "ssrs" is Sandstorm Replication Set? (I don't think that it matters.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume so, I was following

"--replSet", "ssrs", "--oplogSize", "16",
.

Comment thread make-bundle.sh Outdated
Comment thread make-bundle.sh Outdated
Comment thread make-bundle.sh Outdated
Comment thread make-bundle.sh Outdated
Comment thread make-bundle.sh Outdated
@troyjfarrell

Copy link
Copy Markdown
Contributor

Are any licensing implications since this change entails packaging MongoDB 7? Have we discussed that?

@ocdtrekkie

Copy link
Copy Markdown
Collaborator

@troyjfarrell We arguably need to update the about page to indicate the license for MongoDB is SSPL, but SSPL has no serious implications for us, as Sandstorm's use of MongoDB does not provide MongoDB as a service and therefore it effectively functions as GPL3 for us. (There is technically a purity-test fact we are no longer using OSI-approved licensed software there, but between the fact it is effectively GPL3 for us, and it puts our otherwise legacy software in a maintainable state... I am not super worried about it.)

@troyjfarrell

Copy link
Copy Markdown
Contributor

I agree that in practical terms, it's basically GPLv3. We should disclose the SSPL license of the included binaries on the downloads page in the event that someone does not want to run it because it's not OSI approved. Because we aren't exposing MongoDB to apps or end-users, it seems that it doesn't affect the license of our code as I understand it.

@troyjfarrell troyjfarrell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnutt I appreciate the refactoring. It looks good.
@ocdtrekkie Thanks for this licensing note.

@ocdtrekkie
ocdtrekkie merged commit fbe5841 into sandstorm-io:dev Mar 27, 2026
1 check passed
@ocdtrekkie ocdtrekkie removed the ready-for-review We think this is ready for review label Mar 27, 2026
@ocdtrekkie ocdtrekkie mentioned this pull request Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

install-config Installation/configuration issues sandstorm-dev Issues hacking on Sandstorm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants