vBulletin 5 데이터베이스 마이그레이션 - 가져오기 스크립트 오류

우선 이 글로 인해 불쾌감을 느끼실 수 있는 분들에게 사과부터 드리고 싶습니다. 솔직히 월요일부터 이 문제들과 씨름하고 있는데, 지금은 더 이상 Discourse 코드에 대한 디버깅/핫픽스를 하는 것이 지칩니다.

n번째 시도(7번째 이후로는 세는 것을 포기했습니다)를 거친 후, 이제 포기해야 할 것 같습니다. Discourse가 마이그레이션 지원에 많은 시간을 투자하지 않은 것 같기 때문입니다.

가장 큰 문제는 이 거대한 데이터베이스에서 사용되는 문자 인코딩이 utf8mb4인데, 스크립트가 이를 지원하지 않는 것 같다는 점입니다.(?)

utf8(기본값)를 사용하면 오류가 대량으로 발생하며 보고되지만, 스크립트가 그대로 진행되기 때문에 정확히 무슨 일이 일어나고 있는지 명확하지 않습니다. DB의 항목이 건너뛰어지는 건가요? 아니면 지원되지 않는 문자(전형적인 사각형 박스)와 함께 복사되는 건가요?

게다가 동일한 명령어 세트를 정확히 따르고 실행한 최근 세 번의 실행(벌크 임포터 사용) 모두 서로 다른 결과를 낳았습니다. 마지막 실행에서는 토픽 가져오기에 진입하자마자 즉시 오류를 보고했지만 진행을 계속했습니다.(???):

Loading application...
Starting...
Preloading I18n...
Fixing highest post numbers...
Loading imported group ids...
Loading imported user ids...
Loading imported category ids...
Loading imported topic ids...
Loading imported post ids...
Loading groups indexes...
Loading users indexes...
Loading categories indexes...
Loading topics indexes...
Loading posts indexes...
Loading post actions indexes...
Importing categories...
Importing parent categories...
      5 -   1104/sec
Importing children categories...
    500 -   1539/secERROR:  duplicate key value violates unique constraint "unique_index_categories_on_name"
DETAIL:  Key (COALESCE(parent_category_id, '-1'::integer), name)=(-1, Armata Brancaleone) already exists.
CONTEXT:  COPY categories, line 69
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.4.5/lib/pg/connection.rb:204:in `get_last_result'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.4.5/lib/pg/connection.rb:204:in `copy_data'
/var/www/discourse/script/bulk_import/base.rb:720:in `create_records'
/var/www/discourse/script/bulk_import/base.rb:361:in `create_categories'
script/bulk_import/vbulletin5.rb:291:in `import_categories'
script/bulk_import/vbulletin5.rb:69:in `execute'
/var/www/discourse/script/bulk_import/base.rb:98:in `run'
script/bulk_import/vbulletin5.rb:779:in `<main>'
Importing topics...
    600 -   4073/sec
ERROR: undefined method `[]' for nil:NilClass
/var/www/discourse/script/bulk_import/base.rb:513:in `process_topic'
/var/www/discourse/script/bulk_import/base.rb:724:in `block (2 levels) in create_records'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/mysql2/alias_method.rb:8:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/mysql2/alias_method.rb:8:in `each'
/var/www/discourse/script/bulk_import/base.rb:721:in `block in create_records'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.4.5/lib/pg/connection.rb:196:in `copy_data'
/var/www/discourse/script/bulk_import/base.rb:720:in `create_records'
/var/www/discourse/script/bulk_import/base.rb:364:in `create_topics'
script/bulk_import/vbulletin5.rb:321:in `import_topics'
script/bulk_import/vbulletin5.rb:70:in `execute'
/var/www/discourse/script/bulk_import/base.rb:98:in `run'
script/bulk_import/vbulletin5.rb:779:in `<main>'

결국 다음 오류에서 크래시 occurred했습니다:

script/bulk_import/vbulletin5.rb:779:in `<main>'
 572329 -    531/sec
Importing replies...
client_loop: send disconnect: Connection reset

그러나 그 전에 다음과 같은 두 가지 오류를 끊임없이 좌우로 스팸하듯 출력했습니다:

ERROR: undefined method `gsub!' for nil:NilClass
script/bulk_import/vbulletin5.rb:727:in `preprocess_raw'
script/bulk_import/vbulletin5.rb:369:in `block in import_topic_first_posts'
/var/www/discourse/script/bulk_import/base.rb:723:in `block (2 levels) in create_records'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/mysql2/alias_method.rb:8:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/mysql2/alias_method.rb:8:in `each'
/var/www/discourse/script/bulk_import/base.rb:721:in `block in create_records'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.4.5/lib/pg/connection.rb:196:in `copy_data'
/var/www/discourse/script/bulk_import/base.rb:720:in `create_records'
/var/www/discourse/script/bulk_import/base.rb:367:in `create_posts'
script/bulk_import/vbulletin5.rb:361:in `import_topic_first_posts'
script/bulk_import/vbulletin5.rb:71:in `execute'
/var/www/discourse/script/bulk_import/base.rb:98:in `run'
script/bulk_import/vbulletin5.rb:779:in `<main>'

그리고

ERROR: invalid byte sequence in UTF-8
script/bulk_import/vbulletin5.rb:727:in `gsub!'
script/bulk_import/vbulletin5.rb:727:in `preprocess_raw'
script/bulk_import/vbulletin5.rb:369:in `block in import_topic_first_posts'
/var/www/discourse/script/bulk_import/base.rb:723:in `block (2 levels) in create_records'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/mysql2/alias_method.rb:8:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/mysql2/alias_method.rb:8:in `each'
/var/www/discourse/script/bulk_import/base.rb:721:in `block in create_records'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.4.5/lib/pg/connection.rb:196:in `copy_data'
/var/www/discourse/script/bulk_import/base.rb:720:in `create_records'
/var/www/discourse/script/bulk_import/base.rb:367:in `create_posts'
script/bulk_import/vbulletin5.rb:361:in `import_topic_first_posts'
script/bulk_import/vbulletin5.rb:71:in `execute'
/var/www/discourse/script/bulk_import/base.rb:98:in `run'
script/bulk_import/vbulletin5.rb:779:in `<main>'

참고로, 저는 실행할 함수를 주석 처리하는 방식으로 단계별로 진행했고, 계속하기 전에 rake import:ensure_consistency를 실행한 후 방금 실행된 것들을 주석 처리하는 식으로 반복했습니다. 왜냐하면 전체 스크립트를 그냥 다시 실행하면 이전에 실행된 단계에서 중복된 ID를 발견하여 단순히 크래시 발생하기 때문입니다.

"무료 소프트웨어에 대해 불평할 수 없다"는 통상적인 논쟁이 나오기 전에, 저는 다른 오픈 소스 프로젝트에도 기여하고 있으며 무료로 소프트웨어를 개발하고 있지만, 제가 무언가를 릴리스한다면 그것이 작동하고 잘 문서화되어 있어야 한다는 점이 저에게는 매우 중요합니다(그렇지 않으면 '이것이 어떻게 작동하는지’라고 정당하게 질문하는 수천 개의 메시지를 피할 수 없으니까요). 그렇지 않으면 발생하는 모든 버그를 수정할 준비가 되어 있어야 합니다.

Discourse는 훌륭한开箱(experience) 경험을 제공하는 것 같지만, 2022년이라는 점을 잘 인식해야 합니다. 커뮤니티는 이 제품보다 훨씬 전에 존재했습니다. "도입(Adoption)"에는 강력한 마이그레이션 지원이 필요하지만, Discourse의 현재 상태로는 그렇지 않은 것 같습니다.

20GB 데이터베이스는 엣지 케이스임을 인정하지만, 여기서 문제는 크기가 아니라 문자 인코딩이거나 무엇이든 마찬가지입니다. 일관된 오류가 없기 때문이죠. 과거에 같은 고난을 겪은 사람들이 남긴 스레드와 게시물을 찾아다니는 것 외에 문서가 없으며, 우회 방법이 발견되었고 그 이후로 소스 코드가 크게 변경되지 않았기를 바랄 뿐입니다.

이 시점에서, vbulletin에서 넘어오는 모든 사용자에게 마이그레이션 스크립트의 전면적인 개편(진행 중인 것으로 보이지만?)이 완료될 때까지 마이그레이션을 보류할 것을 강력히 권장합니다.