mirror of https://github.com/mongodb/mongo
SERVER-100452 Stop taking DSS and CSS locks in assertNoMovePrimaryInProgress (#32000)
GitOrigin-RevId: 2c684dc524bee7c53ec769203121314528390d8f
This commit is contained in:
parent
889d421c41
commit
ffd9572c91
|
|
@ -65,9 +65,3 @@ deadlock:mongo::(anonymous namespace)::SSLManagerOpenSSL::SSLManagerOpenSSL
|
||||||
race:S2Loop::FindVertex
|
race:S2Loop::FindVertex
|
||||||
race:S2EdgeIndex::IncrementQueryCount
|
race:S2EdgeIndex::IncrementQueryCount
|
||||||
race:S2RegionCoverer::NewCandidate
|
race:S2RegionCoverer::NewCandidate
|
||||||
|
|
||||||
# TODO SERVER-99702 We have a case of lock inversion between ShardingWriteRouter and
|
|
||||||
# assertNoMovePrimaryInProgress. ShardingWriteRouter holds a CSS lock during its lifetime, and with
|
|
||||||
# this lock taken we then acquire a DSS lock. Meanwhile, assertNoMovePrimaryInProgress takes a DSS
|
|
||||||
# lock then a CSS lock, conflicting with the previous lock acquisition order.
|
|
||||||
deadlock:mongo::(anonymous namespace)::assertNoMovePrimaryInProgress
|
|
||||||
|
|
|
||||||
|
|
@ -119,32 +119,6 @@ MONGO_FAIL_POINT_DEFINE(hangAfterDatabaseLock);
|
||||||
MONGO_FAIL_POINT_DEFINE(hangAfterCollModIndexUniqueFullIndexScan);
|
MONGO_FAIL_POINT_DEFINE(hangAfterCollModIndexUniqueFullIndexScan);
|
||||||
MONGO_FAIL_POINT_DEFINE(hangAfterCollModIndexUniqueReleaseIXLock);
|
MONGO_FAIL_POINT_DEFINE(hangAfterCollModIndexUniqueReleaseIXLock);
|
||||||
|
|
||||||
void assertNoMovePrimaryInProgress(OperationContext* opCtx, NamespaceString const& nss) {
|
|
||||||
try {
|
|
||||||
const auto scopedDss =
|
|
||||||
DatabaseShardingState::assertDbLockedAndAcquireShared(opCtx, nss.dbName());
|
|
||||||
auto scopedCss = CollectionShardingState::assertCollectionLockedAndAcquire(opCtx, nss);
|
|
||||||
|
|
||||||
auto collDesc = scopedCss->getCollectionDescription(opCtx);
|
|
||||||
// Only collections that are not registered in the sharding catalog are affected by
|
|
||||||
// movePrimary
|
|
||||||
if (!collDesc.hasRoutingTable()) {
|
|
||||||
if (scopedDss->isMovePrimaryInProgress()) {
|
|
||||||
LOGV2(4945200, "assertNoMovePrimaryInProgress", logAttrs(nss));
|
|
||||||
|
|
||||||
uasserted(ErrorCodes::MovePrimaryInProgress,
|
|
||||||
"movePrimary is in progress for namespace " + nss.toStringForErrorMsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (const DBException& ex) {
|
|
||||||
if (ex.toStatus() != ErrorCodes::MovePrimaryInProgress) {
|
|
||||||
LOGV2(4945201, "Error when getting collection description", "what"_attr = ex.what());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ParsedCollModRequest {
|
struct ParsedCollModRequest {
|
||||||
ParsedCollModIndexRequest indexRequest;
|
ParsedCollModIndexRequest indexRequest;
|
||||||
std::string viewOn = {};
|
std::string viewOn = {};
|
||||||
|
|
|
||||||
|
|
@ -402,8 +402,9 @@ void dropReadyIndexes(OperationContext* opCtx,
|
||||||
|
|
||||||
void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceString& nss) {
|
void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceString& nss) {
|
||||||
try {
|
try {
|
||||||
const auto scopedDss =
|
bool isMovePrimaryInProgress =
|
||||||
DatabaseShardingState::assertDbLockedAndAcquireShared(opCtx, nss.dbName());
|
DatabaseShardingState::assertDbLockedAndAcquireShared(opCtx, nss.dbName())
|
||||||
|
->isMovePrimaryInProgress();
|
||||||
auto scopedCss = CollectionShardingState::assertCollectionLockedAndAcquire(opCtx, nss);
|
auto scopedCss = CollectionShardingState::assertCollectionLockedAndAcquire(opCtx, nss);
|
||||||
|
|
||||||
auto collDesc = scopedCss->getCollectionDescription(opCtx);
|
auto collDesc = scopedCss->getCollectionDescription(opCtx);
|
||||||
|
|
@ -412,7 +413,7 @@ void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceStrin
|
||||||
// Only collections that are not registered in the sharding catalog are affected by
|
// Only collections that are not registered in the sharding catalog are affected by
|
||||||
// movePrimary
|
// movePrimary
|
||||||
if (!collDesc.hasRoutingTable()) {
|
if (!collDesc.hasRoutingTable()) {
|
||||||
if (scopedDss->isMovePrimaryInProgress()) {
|
if (isMovePrimaryInProgress) {
|
||||||
LOGV2(4976500, "assertNoMovePrimaryInProgress", logAttrs(nss));
|
LOGV2(4976500, "assertNoMovePrimaryInProgress", logAttrs(nss));
|
||||||
|
|
||||||
uasserted(ErrorCodes::MovePrimaryInProgress,
|
uasserted(ErrorCodes::MovePrimaryInProgress,
|
||||||
|
|
|
||||||
|
|
@ -319,8 +319,9 @@ bool indexesAlreadyExist(OperationContext* opCtx,
|
||||||
|
|
||||||
void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceString& nss) {
|
void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceString& nss) {
|
||||||
try {
|
try {
|
||||||
const auto scopedDss =
|
bool isMovePrimaryInProgress =
|
||||||
DatabaseShardingState::assertDbLockedAndAcquireShared(opCtx, nss.dbName());
|
DatabaseShardingState::assertDbLockedAndAcquireShared(opCtx, nss.dbName())
|
||||||
|
->isMovePrimaryInProgress();
|
||||||
|
|
||||||
auto scopedCss = CollectionShardingState::assertCollectionLockedAndAcquire(opCtx, nss);
|
auto scopedCss = CollectionShardingState::assertCollectionLockedAndAcquire(opCtx, nss);
|
||||||
|
|
||||||
|
|
@ -328,7 +329,7 @@ void assertNoMovePrimaryInProgress(OperationContext* opCtx, const NamespaceStrin
|
||||||
// All the unsharded, untracked collections owned by the primary are affected by the
|
// All the unsharded, untracked collections owned by the primary are affected by the
|
||||||
// movePrimary.
|
// movePrimary.
|
||||||
if (!collDesc.hasRoutingTable()) {
|
if (!collDesc.hasRoutingTable()) {
|
||||||
if (scopedDss->isMovePrimaryInProgress()) {
|
if (isMovePrimaryInProgress) {
|
||||||
LOGV2(4909200, "assertNoMovePrimaryInProgress", logAttrs(nss));
|
LOGV2(4909200, "assertNoMovePrimaryInProgress", logAttrs(nss));
|
||||||
|
|
||||||
uasserted(ErrorCodes::MovePrimaryInProgress,
|
uasserted(ErrorCodes::MovePrimaryInProgress,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue