From a05500ea7e8a502f495a4ad2dcac861f53602936 Mon Sep 17 00:00:00 2001 From: Zachery Schiller Date: Wed, 8 Sep 2021 11:06:24 -0500 Subject: [PATCH 1/2] Updating read replica list to include #3 --- app/app/db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/app/db.py b/app/app/db.py index e52a7e27ed7..3ed9af5ff0c 100644 --- a/app/app/db.py +++ b/app/app/db.py @@ -9,7 +9,7 @@ def db_for_read(self, model, **hints): Reads go to a randomly-chosen replica if backend node Else go to default DB """ - replicas = ['read_replica_1', 'read_replica_2'] + replicas = ['read_replica_1', 'read_replica_2', 'read_replica_3'] return random.choice(replicas) def db_for_write(self, model, **hints): @@ -23,7 +23,7 @@ def allow_relation(self, obj1, obj2, **hints): Relations between objects are allowed if both objects are in the primary/replica pool. """ - db_set = {'default', 'read_replica_1', 'read_replica_2'} + db_set = {'default', 'read_replica_1', 'read_replica_2', 'read_replica_3'} if obj1._state.db in db_set and obj2._state.db in db_set: return True return True # TODO: be more stringent about this IFF we ever have a situation in which diff tables are on diff DBs From 8a2cdfb4c6f4f179a74fdab3f5b980125af6c1eb Mon Sep 17 00:00:00 2001 From: Zachery Schiller Date: Wed, 8 Sep 2021 11:15:51 -0500 Subject: [PATCH 2/2] Adding read_replica_3 to settings --- app/app/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/app/settings.py b/app/app/settings.py index f941a0cb6cf..938231c3194 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -211,7 +211,8 @@ DATABASES = { 'default': env.db(), 'read_replica_1': env.db('READ_REPLICA_1_DATABASE_URL'), - 'read_replica_2': env.db('READ_REPLICA_2_DATABASE_URL') + 'read_replica_2': env.db('READ_REPLICA_2_DATABASE_URL'), + 'read_replica_3': env.db('READ_REPLICA_3_DATABASE_URL') } DATABASE_ROUTERS = ['app.db.PrimaryDBRouter']