code: func (s *SQLStore) acquireDBLock(steal bool) (bool, string, uint64, error) {
  	s.dbLock.Lock()
  	defer s.dbLock.Unlock()
  	var (
  		lockID  string
  		tick    uint64
  		hasLock bool
  	)
  	tx, err := s.dbLock.db.Begin()
  	if err != nil {
  		return false, "", 0, err
  	}
  	defer func() {
  		if tx != nil {
  			tx.Rollback()
  		}
  	}()
  	r := tx.QueryRow(sqlStmts[sqlDBLockSelect])
  	err = r.Scan(&lockID, &tick)
  	if err != nil && err != sql.ErrNoRows {
  		return false, "", 0, sqlStmtError(sqlDBLockSelect, err)
  	}
  	if err == sql.ErrNoRows || steal || lockID == "" || lockID == s.dbLock.id {
  		// If we are stealing, reset tick to 0 (so it will become 1 in update statement)
  		if steal {
  			tick = 0
  		}
  		stmt := sqlStmts[sqlDBLockUpdate]
  		if err == sql.ErrNoRows {
  			stmt = sqlStmts[sqlDBLockInsert]
  		}
  		if _, err := tx.Exec(stmt, s.dbLock.id, tick+1); err != nil {
  			return false, "", 0, sqlStmtError(sqlDBLockUpdate, err)
  		}
  		hasLock = true
  	}
  	if err := tx.Commit(); err != nil {
  		return false, "", 0, err
  	}
  	tx = nil
  	return hasLock, lockID, tick, nil
  }
docs: // Returns if lock is acquired, the owner and tick value of the lock record.