Begin opens a new transaction. Multiple read-only transactions can be opened at the same time but there can only be one read/write transaction at a time. Attempting to open a read/write transactions while another one is in progress will result in blocking until the current read/write transaction is
(writable bool)
| 80 | // the current read/write transaction is completed. |
| 81 | // All transactions must be closed by calling Commit() or Rollback() when done. |
| 82 | func (db *DB) Begin(writable bool) (tx *Tx, err error) { |
| 83 | // Use TransactionManager so we guard via db.mu when acquiring new transactions |
| 84 | return db.transactionMgr.BeginTx(writable, true) |
| 85 | } |
| 86 | |
| 87 | // newTx returns a newly initialized Tx object at given writable. |
| 88 | func newTx(db *DB, writable bool) (tx *Tx, err error) { |