스레드 및 게시물 마이그레이션 시 Rate Limit 초과

여러분 안녕하세요,

현재 Woltlab (Wbb) 포럼을 Discourse로 마이그레이션하는 도구를 작성 중이며, 어느 정도 완성되면 공유할 예정입니다.

현재까지는 카테고리, 포럼, 사용자 및 사용자 그룹을 비교적 문제 없이 성공적으로 마이그레이션하고 있습니다. 그러나 실행 중 가끔씩 상태가 악화되어, 게시물과 스레드를 처리하는 과정에서 “Ratelimit Exceeded”(레이트 리밋 초과) 오류가 발생하고 있습니다.

제 문제는 아직 초보 단계라 다른 마이그레이션 도구들의 코드 조각들을 여기저기서 모아서 사용하고 있는데, 이 메시지가 어디서 발생하는지 전혀 파악이 안 된다는 점입니다.

이 오류는 Discourse API에서 발생하는 것인가요? 그렇다면 가져오기(Import) 과정 동안 레이트 리미팅을 완전히 비활성화할 수 있는 방법이 있을까요?

def migrate_threads_and_posts
  puts "Migrating threads and posts..."
  @client.query("SELECT * FROM wbb1_thread ORDER BY time ASC").each do |thread_row|
    begin
      next if thread_row[:isDeleted] == 1 || thread_row[:movedThreadID]

      # Ensure lastPosterID maps to a valid user
      last_post_user_id = @user_map[thread_row[:lastPosterID]] || @user_map[thread_row[:userID]]

      # If lastPosterID and userID are null, create a placeholder user
      if last_post_user_id.nil? && thread_row[:lastPoster]
        last_post_user_id = find_or_create_placeholder_user(thread_row[:lastPoster])
      end

      # Ensure a valid user ID exists
      last_post_user_id ||= User.first.id

      # Get topic creator user ID or create placeholder
      creator_user_id = @user_map[thread_row[:userID]] || find_or_create_placeholder_user(thread_row[:username]) || User.first.id

      # Create the topic
      topic = Topic.new(
        title: thread_row[:topic],
        user_id: creator_user_id,
        category_id: @forum_map[thread_row[:boardID]],
        created_at: Time.at(thread_row[:time]),
        updated_at: Time.at(thread_row[:lastPostTime]),
        last_post_user_id: last_post_user_id
      )

      if topic.save(validate: false)
        puts "Imported thread: #{topic.title} (ID: #{topic.id})"

        # Migrate posts
        migrate_posts(thread_row[:threadID], topic.id)
      else
        puts "Error importing thread #{thread_row[:topic]}: #{topic.errors.full_messages.join(', ')}"
      end

      sleep(7) # Increased sleep to avoid rate limiting
    rescue => e
      puts "Exception importing thread #{thread_row[:topic]}: #{e.message}"
    end
  end
end

코드를 최대한 정리하고 주석도 달아 보았습니다. 레이트 리미팅 문제를 도와주실 분이 계셨으면 좋겠습니다.

이 포럼에서도 검색을 해봤는데, 비슷한 문제를 겪는 분들이 많았지만 확실한 해결책은 찾지 못했습니다. 혹시 제가 놓친 부분이 있다면 중복 질문 죄송합니다.

모두 감사합니다.

알겠습니다. 실제로 RateLimiter.disable였군요.

그럼 됐습니다 :slight_smile:

import scripts 중 하나를 시작점으로 사용하면 훨씬 쉬울 것입니다.

아직 존재하는지도 모르는 여러 문제를 해결해 줄 것입니다.

그 문제가 어떤 것일 수 있을까요? 현재 저는 phpbb와 xenforo의 가져오기 스크립트를 참고하고 있습니다.

phpbb3 스크립트는 잘 작성되어 있지만, Ruby에 대한 깊은 이해가 필요합니다. xenforo는 괜찮다고 생각합니다. 원하시는 기능이 있는 것을 찾아보시는 게 좋겠습니다 (DM? 영구 링크? 그룹? 관리자? 정지된 사용자?).

모르는 것을 제가 추측할 수는 없지만, 구 ID를 새 ID와 연결하는 방법과 동일한 데이터가 두 번 가져오지지 않도록 보장하는 방법이 떠오릅니다.