code: func (tx *transaction) Commit() error {
  	// Prevent commits on managed transactions.
  	if tx.managed {
  		tx.close()
  		panic("managed transaction commit not allowed")
  	}
  
  	// Ensure transaction state is valid.
  	if err := tx.checkClosed(); err != nil {
  		return err
  	}
  
  	// Regardless of whether the commit succeeds, the transaction is closed
  	// on return.
  	defer tx.close()
  
  	// Ensure the transaction is writable.
  	if !tx.writable {
  		str := "Commit requires a writable database transaction"
  		return makeDbErr(database.ErrTxNotWritable, str, nil)
  	}
  
  	// Write pending data.  The function will rollback if any errors occur.
  	return tx.writePendingAndCommit()
  }
docs: // Commit commits all changes that have been made to the root metadata bucket
  // and all of its sub-buckets to the database cache which is periodically synced
  // to persistent storage.  In addition, it commits all new blocks directly to
  // persistent storage bypassing the db cache.  Blocks can be rather large, so
  // this help increase the amount of cache available for the metadata updates and
  // is safe since blocks are immutable.
  //
  // This function is part of the database.Tx interface implementation.