TwitchPlaysPokemon / public

Public repo for tracking on-going developer work, user-created issues, and public-facing documentation
5 stars 2 forks source link

Update MongoDB to 4.2 #119

Closed Felk closed 3 years ago

Felk commented 4 years ago

We are currently on MongoDB 3.4 The upgrade path roughly looks like this:

  1. Allow the old core to connect to multiple servers in a replication set. Most likely by just directly providing the mongodb connect uri in the config
  2. Put the current server into replication set mode (this requires a short downtime)
  3. Start a second MongoDB server in the same replication set and wait for it to fully replicate the data and be consistent
  4. Update one server to the next version (e.g. 3.4 to 3.6, 3.6 to 4.0, 4.0 to 4.2).
  5. Start the updated server. Observe if it works properly.
  6. Repeat from step 4, alternating between servers and updating one version jump at a time.

Being on a 4.2 server in replica mode will be required once we use the new core. Having a replica also has the advantage that we can continue to update and move the database server without any downtime in the future.

red031000 commented 4 years ago

sucks to be whoever has to do this, glad it's not me Kappa

Felk commented 4 years ago

I'm gonna do this

Felk commented 4 years ago

plan for monday:

later on, adding another node to the replication set:

as preparation for downtime-less updates:

Felk commented 4 years ago

db is now in replica mode. At least that went smoothly

red031000 commented 4 years ago

pls finish this when possible

Felk commented 4 years ago

I am blocked. m4 needs to provide me with a machine to put a secondary database on

Felk commented 4 years ago

The database is now running in a 2-node replication set. The original database is still on 3.4, while the new one is now on 3.6. I reconfigured the replication set multiple times to transition the stream over to the new node without downtime. That seems to have worked without any problems except one uncritical error during the stepdown in the api:

[2020-07-08 21:43:10,814] tpp.webext log_exception():1892 ERROR    Exception on /api/badges [GET]
Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\flask\app.py", line 1948, in full_dispatch_request
    rv = self.preprocess_request()
  ...
  File "C:\Program Files\Python36\lib\site-packages\pymongo\helpers.py", line 136, in _check_command_response
    raise NotMasterError(errmsg, response)
pymongo.errors.NotMasterError: not master

I made the second node master with 1 vote 1 priority, took away the original database's votes and priority, and shut that one down. The stream is now operating on the new node on 3.6. I will let it run like that for a while before performing further updates.

Felk commented 3 years ago

stream is now running in a 3-node replica set config on MongoDB version 4.2