Skip to content

Commit

Permalink
Fix EM flag for replica sets (#3982)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsolo committed Sep 30, 2022
1 parent 883047c commit 9ea4e9e
Showing 1 changed file with 6 additions and 12 deletions.
Expand Up @@ -698,11 +698,6 @@ const _issueUpdateReplicaSetOp = async (
// First try updateReplicaSet via URSM
// Fallback to EntityManager when relay errors
try {
if (!config.get('entityManagerReplicaSetEnabled')) {
throw new Error(
'Fallback to URSM writes because EntityManager is disabled'
)
}
await audiusLibs.contracts.UserReplicaSetManagerClient._updateReplicaSet(
userId,
newReplicaSetSPIds[0], // new primary
Expand All @@ -715,6 +710,10 @@ const _issueUpdateReplicaSetOp = async (
]
)
} catch (err) {
if (!config.get('entityManagerReplicaSetEnabled')) {
throw err
}

logger.info(
`[_issueUpdateReplicaSetOp] updating replica set now ${
Date.now() - startTimeMs
Expand Down Expand Up @@ -851,22 +850,17 @@ const _canReconfig = async ({
let error
try {
let chainPrimarySpId, chainSecondarySpIds
// Attempt to get replica set from DN when entity manager is enabled
// Fallback to URSM
try {
if (config.get('entityManagerReplicaSetEnabled')) {
const encodedUserId = libs.Utils.encodeHashId(userId)
const spResponse = await libs.discoveryProvider.getUserReplicaSet({
encodedUserId
})
if (!spResponse) {
throw new Error('User replica set is not on discovery')
}
chainPrimarySpId = spResponse?.primarySpID
chainSecondarySpIds = [
spResponse?.secondary1SpID,
spResponse?.secondary2SpID
]
} catch (err) {
} else {
const response =
await libs.contracts.UserReplicaSetManagerClient.getUserReplicaSet(
userId
Expand Down

0 comments on commit 9ea4e9e

Please sign in to comment.