func (l *MySQLLock) Acquire(lockName string, wait time.Duration) error {
	l.Lock()

	// start transaction
	tx, ok := l.TXMap[lockName]
	if !ok {
		l.TXMap[lockName] = l.MySQLClient.Begin()
		tx = l.TXMap[lockName]
	}

	l.Unlock()

	if wait < 1*time.Second {
		wait = 1 * time.Second
	}

	var err error
	// The length of time in seconds an InnoDB transaction waits for a row lock before giving up.
	result := tx.Exec("SET @@session.innodb_lock_wait_timeout = ?", int(wait/time.Second))
	err = result.Error
	if err != nil {
		return err
	}

	result = tx.Exec("select * from _lock_store where name = ? for update", lockName)
	err = result.Error
	// Error 1205: Lock wait timeout exceeded; try restarting transaction
	return err
}
// Lock :If the lock cannot be obtained, it will keep blocking
Lock :If the lock cannot be obtained, it will keep blocking
// Lock : If the lock cannot be obtained it will keep blocking
func (l *MySQLLock) Acquire(lockName string, wait time.Duration) error {
	l.Lock()
	tx, ok := l.TXMap[lockName]
	if !ok {
		l.TXMap[lockName] = l.MySQLClient.Begin()
		tx = l.TXMap[lockName]
	}
	l.Unlock()
	if wait < 1*time.Second {
		wait = 1 * time.Second
	}
	var err error
	result := tx.Exec("SET @@session.innodb_lock_wait_timeout = ?", int(wait/time.Second))
	err = result.Error
	if err != nil {
		return err
	}
	result = tx.Exec("select * from _lock_store where name = ? for update", lockName)
	err = result.Error
	return err
}
func ( l * MySQLLock ) Acquire ( lockName string , wait time . Duration ) error { l . Lock ( ) tx , ok := l . TXMap [ lockName ] if ! ok { l . TXMap [ lockName ] = l . MySQLClient . Begin ( ) tx = l . TXMap [ lockName ] } l . Unlock ( ) if wait < 1 * time . Second { wait = 1 * time . Second } var err error result := tx . Exec ( " " , int ( wait / time . Second ) ) err = result . Error if err != nil { return err } result = tx . Exec ( " " , lockName ) err = result . Error return err }
Lock :If the lock cannot be obtained, it will keep blocking
Lock : If the lock cannot be obtained it will keep blocking
// start transaction // The length of time in seconds an InnoDB transaction waits for a row lock before giving up. // Error 1205: Lock wait timeout exceeded; try restarting transaction