Exemple #1
0
void WriteBatchExecutor::execUpdate( const BatchItemRef& updateItem,
                                     BSONObj* upsertedId,
                                     WriteErrorDetail** error ) {

    // BEGIN CURRENT OP
    scoped_ptr<CurOp> currentOp( beginCurrentOp( _client, updateItem ) );
    incOpStats( updateItem );

    WriteOpResult result;

    WriteUnitOfWork wunit(_txn->recoveryUnit());
    multiUpdate( _txn, updateItem, &result );
    wunit.commit();

    if ( !result.getStats().upsertedID.isEmpty() ) {
        *upsertedId = result.getStats().upsertedID;
    }
    // END CURRENT OP
    incWriteStats( updateItem, result.getStats(), result.getError(), currentOp.get() );
    finishCurrentOp( _txn, _client, currentOp.get(), result.getError() );

    if ( result.getError() ) {
        result.getError()->setIndex( updateItem.getItemIndex() );
        *error = result.releaseError();
    }
}
Exemple #2
0
    void WriteBatchExecutor::execUpdate( const BatchItemRef& updateItem,
                                         BSONObj* upsertedId,
                                         WriteErrorDetail** error ) {

        // Updates currently do a lot of the lock management internally

        const BatchedCommandRequest& request = *updateItem.getRequest();
        const NamespaceString nss( updateItem.getRequest()->getNS() );

        // BEGIN CURRENT OP
        scoped_ptr<CurOp> currentOp( beginCurrentOp( _client, updateItem ) );
        incOpStats( updateItem );

        WriteOpResult result;

        {
            ///////////////////////////////////////////
            Lock::DBWrite writeLock( nss.ns() );
            ///////////////////////////////////////////

            // Check version once we're locked

            if ( checkShardVersion( &shardingState, request, &result.error ) ) {

                // Context once we're locked, to set more details in currentOp()
                // TODO: better constructor?
                Client::Context writeContext( nss.ns(),
                                              storageGlobalParams.dbpath,
                                              false /* don't check version */);

                multiUpdate( updateItem, &result );

                incWriteStats( updateItem, result.stats, result.error, currentOp.get() );

                if ( !result.stats.upsertedID.isEmpty() ) {
                    *upsertedId = result.stats.upsertedID.getOwned();
                }
            }
        }

        // END CURRENT OP
        finishCurrentOp( _client, currentOp.get(), result.error );

        if ( result.error ) {
            result.error->setIndex( updateItem.getItemIndex() );
            *error = result.releaseError();
        }
    }
Exemple #3
0
void WriteBatchExecutor::execUpdate( const BatchItemRef& updateItem,
                                     BSONObj* upsertedId,
                                     WriteErrorDetail** error ) {

    // BEGIN CURRENT OP
    scoped_ptr<CurOp> currentOp( beginCurrentOp( _client, updateItem ) );
    incOpStats( updateItem );

    WriteOpResult result;
    multiUpdate( updateItem, &result );
    incWriteStats( updateItem, result.stats, result.error, currentOp.get() );

    if ( !result.stats.upsertedID.isEmpty() ) {
        *upsertedId = result.stats.upsertedID;
    }

    // END CURRENT OP
    finishCurrentOp( _client, currentOp.get(), result.error );

    if ( result.error ) {
        result.error->setIndex( updateItem.getItemIndex() );
        *error = result.releaseError();
    }
}