200,000개 게시글이 있는 포럼을 새 서버로 마이그레이션했습니다. 다운타임이 발생하지 않도록 라이브 사이트는 읽기 전용 모드로 전환해 두었습니다.
사용자가 설치 화면이나 복원 과정에서 발생할 수 있는 문제를 보지 않도록 백업을 다른 서브도메인(dev.example.com 같은)에 복원했습니다.
복원이 완료되자마자 DNS를 새 서버로 가리키고 app.yml 파일의 도메인을 정상적인 forum.example.com으로 변경했습니다.
그런데 기존 게시글의 이모티콘(스마일리)이 전부 dev.example.com 서버를 가리키고 있어서 rake:rebake를 실행했습니다.
약 1,000~2,000개 게시글을 처리한 후 데이터베이스 연결 관련 오류로 크래시가 발생합니다.
아래는 일부 로그 내용입니다:
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/exe/bundle:45:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/exe/bundle:33:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
1999 / 200968 ( 1.0%)
Failed to rebake (topic_id: 78730, post_id: 210607)
PG::ConnectionBad: PQsocket() can't get socket descriptor
/var/www/discourse/lib/tasks/posts.rake:108:in `rebake_posts_all_sites'
/var/www/discourse/lib/tasks/posts.rake:7:in `block in <main>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Caused by:
PG::ConnectionBad: PQsocket() can't get socket descriptor
현재는 dev.example.com 도메인을 forum.example.com 도메인으로 리다이렉트하여 이미지 로딩은 해결했지만, 이는 임시 조치일 뿐입니다.
이 오류를 해결하여 모든 게시글을 리베이킹(rebake)할 수 있는 방법이 있을까요? 데이터베이스에 부하가 너무 많이 걸리는 것일까요?
