3 ms·
1) start with dual-write to both the DBs for all the writes. 2) all reads from Mongo 3) in the background start data migration, one key/document at a time; tr
by nishantvyas 7y ago
1) start with dual-write to both the DBs for all the writes.
2) all reads from Mongo
3) in the background start data migration, one key/document at a time; transform Mongo document into RDBMS table/rows and insert... have mongo document id as primary key for main table... for every document migration/insert, lock the corresponding RDBMS row, this will ensure data consistency...
4) create code path to read from RDBMS.
5) test it in stage for different fail-case scenarios...
6) ideally, do canary type push to single server etc in prod to see if read from RDBMS seems fine (this assumes #3 is done)
actual steps may vary... but these are high-level steps....hope it helps...
- vosper 7y agoThanks, that's helpful! Regarding locking the database rows, I'm a little unclear about how that helps? Is the idea that once a record has been migrated from mongo to RDBMS you want to lock the data in the latter so that no-one accidentally updates the record in the RDBMS and not in Mongo? And therefore Mongo remains the definite source of truth?
- nishantvyas 7y agobasically locking will create the serializability for that document... so if there are concurrent updates on mongo side it will have to wait... also for step-1 in dual write it should be automic/two-phase between mongo and RDBMS.