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 monograph issue119 #42

Open
wants to merge 3 commits into
base: monograph-4.0.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 50 additions & 51 deletions buildscripts/resmokeconfig/suites/core_monograph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -960,59 +960,58 @@ selector:
- jstests/core_standalone/read_concern.js
- jstests/core_standalone/write_concern.js
# - Tests that would be excluded from suite core_monograph
# - jstests/core/txns/abort_expired_transaction.js # 40: Transaction numbers are only allowed on a replica set member or mongos
# - jstests/core/txns/abort_transaction_thread_does_not_block_on_locks.js
# - jstests/core/txns/abort_transactions_on_FCV_downgrade.js
# - jstests/core/txns/aggregation_in_transaction.js
# - jstests/core/txns/ban_tailable_cursor.js
# - jstests/core/txns/banned_txn_dbs.js
# - jstests/core/txns/basic_causal_consistency.js
# - jstests/core/txns/commands_not_allowed_in_txn.js
# - jstests/core/txns/concurrent_drops_and_creates.js
# - jstests/core/txns/do_txn_atomicity.js
# - jstests/core/txns/do_txn_basic.js
# - jstests/core/txns/find_and_modify_in_transaction.js
# - jstests/core/txns/finished_transaction_error_handling.js
# - jstests/core/txns/kill_cursors_in_transaction.js
# - jstests/core/txns/kill_op_on_txn_expiry.js
# - jstests/core/txns/kill_sessions_kills_transaction.js
# - jstests/core/txns/kill_transaction_cursors_after_commit.js
# - jstests/core/txns/kill_txn_cursor.js
# - jstests/core/txns/libs/write_conflicts.js
# - jstests/core/txns/list_collections_not_blocked_by_txn.js
# - jstests/core/txns/multi_delete_in_transaction.js
# - jstests/core/txns/multi_statement_transaction.js
# - jstests/core/txns/multi_statement_transaction_abort.js
# - jstests/core/txns/multi_statement_transaction_command_args.js
# - jstests/core/txns/multi_statement_transaction_using_api.js
# - jstests/core/txns/multi_update_in_transaction.js
# - jstests/core/txns/no_implicit_collection_creation_in_txn.js
# - jstests/core/txns/no_read_concern_snapshot_outside_txn.js
# - jstests/core/txns/no_read_or_write_concern_inside_txn.js
# - jstests/core/txns/no_writes_to_system_collections_in_txn.js
# - jstests/core/txns/non_transactional_operations_on_session_with_transaction.js
# - jstests/core/txns/noop_createIndexes_not_blocked_by_txn.js
# - jstests/core/txns/only_allow_transactions_on_FCV_40.js
# - jstests/core/txns/read_own_multikey_writes.js
# - jstests/core/txns/repeatable_reads_in_transaction.js
# - jstests/core/txns/shell_prompt_in_transaction.js
# - jstests/core/txns/speculative_snapshot_includes_all_writes.js
# - jstests/core/txns/start_transaction_with_read.js
# - jstests/core/txns/statement_ids_accepted.js
# - jstests/core/txns/transaction_error_handling.js
# - jstests/core/txns/transactions_block_ddl.js
# - jstests/core/txns/transactions_profiling.js
# - jstests/core/txns/transactions_profiling_with_drops.js
# - jstests/core/txns/transactions_write_conflicts.js
# - jstests/core/txns/transactions_write_conflicts_unique_indexes.js
# - jstests/core/txns/upconvert_read_concern.js
# - jstests/core/txns/view_reads_in_transaction.js
# - jstests/core/txns/write_conflicts_with_non_txns.js
- jstests/core/txns/abort_expired_transaction.js
# - jstests/core/txns/abort_transaction_thread_does_not_block_on_locks.js # startParallelShell
# - jstests/core/txns/abort_transactions_on_FCV_downgrade.js # unsupported maxTimeMS in txservice
- jstests/core/txns/aggregation_in_transaction.js
# - jstests/core/txns/ban_tailable_cursor.js # Unsupported feature. Do not set the value of capped field to true.
- jstests/core/txns/banned_txn_dbs.js
- jstests/core/txns/basic_causal_consistency.js
# - jstests/core/txns/commands_not_allowed_in_txn.js # Unsupported feature. geoNear command.
# - jstests/core/txns/concurrent_drops_and_creates.js # 67:Error: no write error: { "nInserted" : 1 }
# - jstests/core/txns/do_txn_atomicity.js # Unsupported feature. Do not set the value of capped field to true.
- jstests/core/txns/do_txn_basic.js #
- jstests/core/txns/find_and_modify_in_transaction.js
- jstests/core/txns/finished_transaction_error_handling.js
# - jstests/core/txns/kill_cursors_in_transaction.js # startParallelShell
# - jstests/core/txns/kill_op_on_txn_expiry.js # workerThread.start();
# - jstests/core/txns/kill_sessions_kills_transaction.js # killSessions stuck during abort
- jstests/core/txns/kill_transaction_cursors_after_commit.js
- jstests/core/txns/kill_txn_cursor.js
- jstests/core/txns/libs/write_conflicts.js
- jstests/core/txns/list_collections_not_blocked_by_txn.js
- jstests/core/txns/multi_delete_in_transaction.js
- jstests/core/txns/multi_statement_transaction.js
# - jstests/core/txns/multi_statement_transaction_abort.js # 160: Error: command worked when it should have failed: { "n" : 1, "ok" : 1 } Monograph detect conflict at commit phase.
# - jstests/core/txns/multi_statement_transaction_command_args.js # Error: error loading js file: jstests/core/txns/multi_statement_transaction_command_args.js @(shell):1:1 TypeError: TestData is undefined
- jstests/core/txns/multi_statement_transaction_using_api.js
- jstests/core/txns/multi_update_in_transaction.js
- jstests/core/txns/no_implicit_collection_creation_in_txn.js
# - jstests/core/txns/no_read_concern_snapshot_outside_txn.js # 85: Error: command worked when it should have failed: { "n" : 1, "ok" : 1 }
- jstests/core/txns/no_read_or_write_concern_inside_txn.js
- jstests/core/txns/no_writes_to_system_collections_in_txn.js
- jstests/core/txns/non_transactional_operations_on_session_with_transaction.js
# - jstests/core/txns/noop_createIndexes_not_blocked_by_txn.js # stuck
# - jstests/core/txns/only_allow_transactions_on_FCV_40.js # 36: Error: ["3.6"] != ["4.0"] are not equal : { "_id" : "featureCompatibilityVersion", "version" : "3.6" }
- jstests/core/txns/read_own_multikey_writes.js
- jstests/core/txns/repeatable_reads_in_transaction.js
- jstests/core/txns/shell_prompt_in_transaction.js
# - jstests/core/txns/speculative_snapshot_includes_all_writes.js # startParallelShell
- jstests/core/txns/start_transaction_with_read.js
# - jstests/core/txns/statement_ids_accepted.js # 249: This storage engine does not support prepared transactions
- jstests/core/txns/transaction_error_handling.js
# - jstests/core/txns/transactions_block_ddl.js # unsupported maxTimeMS in txservice
# - jstests/core/txns/transactions_profiling.js # 40: Error: assert failed : could not find any entries in the profile collection matching filter: undefined
# - jstests/core/txns/transactions_profiling_with_drops.js # startParallelShell
# - jstests/core/txns/transactions_write_conflicts.js # 59: Error: command worked when it should have failed: { "n" : 1, "ok" : 1 } Monograph detect conflict at commit phase.
# - jstests/core/txns/transactions_write_conflicts_unique_indexes.js # 36: Error: command worked when it should have failed: { "n" : 1, "ok" : 1 }
- jstests/core/txns/upconvert_read_concern.js
- jstests/core/txns/view_reads_in_transaction.js
# - jstests/core/txns/write_conflicts_with_non_txns.js # 71: Error: command worked when it should have failed: { "n" : 1, "ok" : 1 }

exclude_files:
# Transactions are not supported on MongoDB standalone nodes, so we do not run these tests in the
# 'core' suite. Instead we run them against a 1-node replica set in the 'core_txns' suite.
- jstests/core/txns/**/*.js
# Transactions have been supported on MongoDB standalone node.
# - jstests/core/txns/**/*.js
executor:
archive:
hooks:
Expand Down
3 changes: 2 additions & 1 deletion src/mongo/db/commands/find_and_modify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,13 @@ class CmdFindAndModify : public BasicCommand {
<< " within a transaction.",
!(inTransaction && nsString.isSystem()));

/* This limitation does not exist in Monograph.
const auto replCoord = repl::ReplicationCoordinator::get(opCtx->getServiceContext());
uassert(50777,
str::stream() << "Cannot write to unreplicated collection " << nsString.ns()
<< " within a transaction.",
!(inTransaction && replCoord->isOplogDisabledFor(opCtx, nsString)));

*/

const auto stmtId = 0;
if (opCtx->getTxnNumber()) {
Expand Down
4 changes: 3 additions & 1 deletion src/mongo/db/commands/write_commands/write_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void serializeReply(OperationContext* opCtx,
BSONSizeTracker upsertInfoSizeTracker;
BSONSizeTracker errorsSizeTracker;

auto errorMessage = [&, errorSize = size_t(0) ](StringData rawMessage) mutable {
auto errorMessage = [&, errorSize = size_t(0)](StringData rawMessage) mutable {
// Start truncating error messages once both of these limits are exceeded.
constexpr size_t kErrorSizeTruncationMin = 1024 * 1024;
constexpr size_t kErrorCountTruncationMin = 2;
Expand Down Expand Up @@ -268,11 +268,13 @@ class WriteCommand::InvocationBase : public CommandInvocation {
str::stream() << "Cannot write to system collection " << ns().toString()
<< " within a transaction.",
!ns().isSystem());
/* This limitation does not exist in Monograph.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
uassert(50790,
str::stream() << "Cannot write to unreplicated collection " << ns().toString()
<< " within a transaction.",
!replCoord->isOplogDisabledFor(opCtx, ns()));
*/
}

const OpMsgRequest* _request;
Expand Down
40 changes: 26 additions & 14 deletions src/mongo/db/concurrency/monograph_locker_noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

#pragma once

#include "mongo/db/concurrency/lock_manager_defs.h"
#include "mongo/util/time_support.h"
#include <utility>

#include "mongo/db/concurrency/lock_manager_defs.h"
#include "mongo/db/concurrency/locker.h"
#include "mongo/util/time_support.h"

namespace mongo {
// Global lock. Every server operation, which uses the Locker must acquire this lock at least
Expand Down Expand Up @@ -67,36 +67,35 @@ class MonographLockerNoop final : public Locker {
}

LockerId getId() const override {
MONGO_UNREACHABLE;
return {};
}

stdx::thread::id getThreadId() const override {
MONGO_UNREACHABLE;
return {};
}

void updateThreadIdToCurrentThread() override {
MONGO_UNREACHABLE;
// No-op
}

void unsetThreadId() override {
MONGO_UNREACHABLE;
// No-op
}

void setSharedLocksShouldTwoPhaseLock(bool sharedLocksShouldTwoPhaseLock) override {
MONGO_UNREACHABLE;
}

void setMaxLockTimeout(Milliseconds maxTimeout) override {
MONGO_UNREACHABLE;
_maxLockTimeout = maxTimeout;
}

bool hasMaxLockTimeout() override {
MONGO_UNREACHABLE;
return false;
return static_cast<bool>(_maxLockTimeout);
}

void unsetMaxLockTimeout() override {
MONGO_UNREACHABLE;
_maxLockTimeout = boost::none;
}

LockResult lockGlobal(OperationContext* opCtx, LockMode mode) override {
Expand Down Expand Up @@ -224,11 +223,17 @@ class MonographLockerNoop final : public Locker {
}

void getLockerInfo(LockerInfo* lockerInfo) const override {
MONGO_UNREACHABLE;
invariant(lockerInfo);

// Zero-out the contents
lockerInfo->locks.clear();
lockerInfo->waitingResource = ResourceId();
lockerInfo->stats.reset();
}

boost::optional<LockerInfo> getLockerInfo() const override {
return boost::none;
// Return a default-constructed LockerInfo object instead of boost::none.
return {LockerInfo{}};
}

// Refer to LockerImpl<IsForMMAPV1>::saveLockStateAndUnlock
Expand Down Expand Up @@ -293,11 +298,11 @@ class MonographLockerNoop final : public Locker {
}

void releaseTicket() override {
MONGO_UNREACHABLE;
// No-op
}

void reacquireTicket(OperationContext* opCtx) override {
MONGO_UNREACHABLE;
// No-op
}

void dump() const override {
Expand Down Expand Up @@ -343,6 +348,13 @@ class MonographLockerNoop final : public Locker {
// work completes. Value of 0 means we are not inside a write unit of work.
int _wuowNestingLevel{0};

// If this is set, dictates the max number of milliseconds that we will wait for lock
// acquisition. Effectively resets lock acquisition deadlines to time out sooner. If set to 0,
// for example, lock attempts will time out immediately if the lock is not immediately
// available.
// This variable is and serves no purpose for Monograph.
boost::optional<Milliseconds> _maxLockTimeout;

// Indicates whether the client is active reader/writer or is queued.
// AtomicWord<ClientState> _clientState{kInactive};
};
Expand Down
2 changes: 2 additions & 0 deletions src/mongo/db/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ ExitCode _initAndListen(int listenPort) {

serviceContext->setFastClockSource(FastClockSourceFactory::create(Milliseconds(10)));
auto opObserverRegistry = stdx::make_unique<OpObserverRegistry>();
/* Disable the sharding op observer for Monograph
opObserverRegistry->addObserver(stdx::make_unique<OpObserverShardingImpl>());
*/
opObserverRegistry->addObserver(stdx::make_unique<UUIDCatalogObserver>());

if (serverGlobalParams.clusterRole == ClusterRole::ShardServer) {
Expand Down
4 changes: 3 additions & 1 deletion src/mongo/db/initialize_operation_session_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ boost::optional<OperationSessionInfoFromClient> initializeOperationSessionInfo(
invariant(osi.getSessionId());
stdx::lock_guard<Client> lk(*opCtx->getClient());

// This limitation does not exist in Monograph.
uassert(ErrorCodes::IllegalOperation,
"Transaction numbers are only allowed on a replica set member or mongos",
isReplSetMemberOrMongos);
true // isReplSetMemberOrMongos
);
uassert(ErrorCodes::IllegalOperation,
"Transaction numbers are only allowed on storage engines that support "
"document-level locking",
Expand Down
12 changes: 11 additions & 1 deletion src/mongo/db/operation_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,17 @@ class OperationContext : public Decorable<OperationContext> {

std::pair<const std::function<void()>*, const std::function<void()>*> getCoroutineFunctors()
const {
return {_coroYield, _coroResume};
// Some temporary, auxiliary and background threads, such as
// `startPeriodicThreadToAbortExpiredTransactions` and `js`, invoke this function. These
// threads share the same OperationContext with the worker thread named `thread_group`, but
// they should not call yield or resume functions. Therefore, we need to verify the thread
// name.
StringData threadName = getThreadName();
if (MONGO_likely(threadName.startsWith("thread_group"))) {
return {_coroYield, _coroResume};
} else {
return {nullptr, nullptr};
}
}

private:
Expand Down
40 changes: 21 additions & 19 deletions src/mongo/db/service_entry_point_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ void execCommandDatabase(OperationContext* opCtx,
_extractReadConcern(invocation.get(), request.body, upconvertToSnapshot));
}

/* No need for Monograph
if (readConcernArgs.getArgsAtClusterTime()) {
uassert(ErrorCodes::InvalidOptions,
"atClusterTime is only used for testing",
Expand All @@ -850,26 +851,26 @@ void execCommandDatabase(OperationContext* opCtx,
opCtx->lockState()->setSharedLocksShouldTwoPhaseLock(true);
}

// @starrysky no need for sharding
// auto& oss = OperationShardingState::get(opCtx);
auto& oss = OperationShardingState::get(opCtx);

// if (!opCtx->getClient()->isInDirectClient() &&
// readConcernArgs.getLevel() != repl::ReadConcernLevel::kAvailableReadConcern &&
// (iAmPrimary ||
// (readConcernArgs.hasLevel() || readConcernArgs.getArgsAfterClusterTime()))) {
// oss.initializeClientRoutingVersions(invocation->ns(), request.body);

// auto const shardingState = ShardingState::get(opCtx);
// if (oss.hasShardVersion() || oss.hasDbVersion()) {
// uassertStatusOK(shardingState->canAcceptShardedCommands());
// }
if (!opCtx->getClient()->isInDirectClient() &&
readConcernArgs.getLevel() != repl::ReadConcernLevel::kAvailableReadConcern &&
(iAmPrimary ||
(readConcernArgs.hasLevel() || readConcernArgs.getArgsAfterClusterTime()))) {
oss.initializeClientRoutingVersions(invocation->ns(), request.body);

auto const shardingState = ShardingState::get(opCtx);
if (oss.hasShardVersion() || oss.hasDbVersion()) {
uassertStatusOK(shardingState->canAcceptShardedCommands());
}

// // Handle config optime information that may have been sent along with the command.
// rpc::advanceConfigOptimeFromRequestMetadata(opCtx);
// }
// Handle config optime information that may have been sent along with the command.
rpc::advanceConfigOptimeFromRequestMetadata(opCtx);
}

// oss.setAllowImplicitCollectionCreation(allowImplicitCollectionCreationField);
// ScopedOperationCompletionShardingActions operationCompletionShardingActions(opCtx);
oss.setAllowImplicitCollectionCreation(allowImplicitCollectionCreationField);
ScopedOperationCompletionShardingActions operationCompletionShardingActions(opCtx);
*/

// This may trigger the maxTimeAlwaysTimeOut failpoint.
auto status = opCtx->checkForInterruptNoAssert();
Expand All @@ -894,8 +895,9 @@ void execCommandDatabase(OperationContext* opCtx,
<< rpc::TrackingMetadata::get(opCtx).toString();
rpc::TrackingMetadata::get(opCtx).setIsLogged(true);
}

behaviors.waitForReadConcern(opCtx, invocation.get(), request);

// No need for Monograph
// behaviors.waitForReadConcern(opCtx, invocation.get(), request);

try {
if (!runCommandImpl(opCtx,
Expand Down
Loading