Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EM flag for replica sets #3982

Merged
merged 3 commits into from
Sep 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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