def start_transaction(options = nil)
      if options
        Lint.validate_read_concern_option(options[:read_concern])
      end

      check_if_ended!

      if within_states?(STARTING_TRANSACTION_STATE, TRANSACTION_IN_PROGRESS_STATE)
        raise Mongo::Error::InvalidTransactionOperation.new(
          Mongo::Error::InvalidTransactionOperation::TRANSACTION_ALREADY_IN_PROGRESS)
      end

      next_txn_num
      @txn_options = options || @options[:default_transaction_options] || {}

      if txn_write_concern && WriteConcern.send(:unacknowledged?, txn_write_concern)
        raise Mongo::Error::InvalidTransactionOperation.new(
          Mongo::Error::InvalidTransactionOperation::UNACKNOWLEDGED_WRITE_CONCERN)
      end

      @state = STARTING_TRANSACTION_STATE
      @already_committed = false
    end
def start_transaction(options = nil)
      if options
        Lint.validate_read_concern_option(options[:read_concern])
      end

      check_if_ended!

      if within_states?(STARTING_TRANSACTION_STATE, TRANSACTION_IN_PROGRESS_STATE)
        raise Mongo::Error::InvalidTransactionOperation.new(
          Mongo::Error::InvalidTransactionOperation::TRANSACTION_ALREADY_IN_PROGRESS)
      end

      next_txn_num
      @txn_options = options || @options[:default_transaction_options] || {}

      if txn_write_concern && WriteConcern.send(:unacknowledged?, txn_write_concern)
        raise Mongo::Error::InvalidTransactionOperation.new(
          Mongo::Error::InvalidTransactionOperation::UNACKNOWLEDGED_WRITE_CONCERN)
      end

      @state = STARTING_TRANSACTION_STATE
      @already_committed = false
    end
Places subsequent operations in this session into a new transaction.

 Note that the transaction will not be started on the server until an
 operation is performed after start_transaction is called.

 @example Start a new transaction
   session.start_transaction(options)

 @param [ Hash ] options The options for the transaction being started.

 @option options [ Hash ] read_concern The read concern options hash,
   with the following optional keys:
   - *:level* -- the read preference level as a symbol; valid values
      are *:local*, *:majority*, and *:snapshot*
 @option options [ Hash ] :write_concern The write concern options. Can be :w =>
   Integer|String, :fsync => Boolean, :j => Boolean.
 @option options [ Hash ] :read The read preference options. The hash may have the following
   items:
   - *:mode* -- read preference specified as a symbol; the only valid value is
     *:primary*.

 @raise [ Error::InvalidTransactionOperation ] If a transaction is already in
   progress or if the write concern is unacknowledged.

 @since 2.6.0