مشاكل الترقية: فشل الترقية بسبب مفتاح مكرر، فشل استعادة اللقطة

يبدو أنني واجهت مشكلة عند تشغيل أحدث ترقية، حيث فشلت العملية بسبب ما يلي:

PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_users_on_username_lower"
DETAIL:  Key (username_lower)=(scottie) already exists.

حاولت التعافي بمحاولة حذف هذا المستخدم عبر الوصول إما إلى وحدة تحكم Rails أو قاعدة بيانات Postgres مباشرة، لكنني أستمر في الحصول على خطأ يفيد بأن الخادم غير قيد التشغيل.

فيما يلي محاولة مني لتشغيل rails بعد بدء التطبيق:

FAILED

--------------------

Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 3743 exit 1>

Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'

exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}

c744729efb7a5813699e2fe8fa46ab551352d45ada8dcb9204121508364f8438

** FAILED TO BOOTSTRAP ** يرجى التمرير للأعلى والبحث عن رسائل الخطأ السابقة، فقد يكون هناك أكثر من خطأ.

قد يساعد ./discourse-doctor في تشخيص المشكلة.

root@kForum:/var/discourse# ./launcher start app

starting up existing container

+ /usr/bin/docker start app

app

root@kForum:/var/discourse# ./launcher enter app

root@kForum-app:/var/www/discourse# rails c

bundler: failed to load command: pry (/var/www/discourse/vendor/bundle/ruby/2.7.0/bin/pry)

PG::ConnectionBad: could not connect to server: No such file or directory

Is the server running locally and accepting

connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

فيما يلي محاولة مني لتشغيل postgres:

root@kForum:/var/discourse# ./launcher enter app

root@kForum-app:/var/www/discourse# su discourse

discourse@kForum-app:/var/www/discourse$ psql discourse

psql: error: could not connect to server: No such file or directory

Is the server running locally and accepting

connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

discourse@kForum-app:/var/www/discourse$

أقوم باستعادة صورة سابقة من DigitalOcean للعودة إلى حالة عمل، لكن الجزء الغريب (المخيف؟) هو أن استعادة الصورة لم تعيد الموقع إلى العمل مرة أخرى. تم أخذ هذه الصورة قبل أكثر من 24 ساعة، عندما كنت أعرف أن المنتديات تعمل بشكل جيد، لذا يجب أن لا يكون لها علاقة بالترقية التي حاولت تنفيذها.

في الصورة المستعادة، هذا هو الخطأ الذي أراه عند محاولة إيقاف/بدء/إعادة تشغيل التطبيق:

root@kForum:/var/discourse# ./launcher restart app

+ /usr/bin/docker stop -t 10 app

app

starting up existing container

+ /usr/bin/docker start app

Error response from daemon: container "a1023d05a7b4de25ded1aa69ad49caed9fa59d15fa8e8130d32db82934139e6b": already exists

Error: failed to start containers: app

root@kForum:/var/discourse#

أخيرًا، قمت بتشغيل discourse-doctor، وهذا يبدو جزءًا ذا صلة من الفشل؟

Checking cluster versions                                   ok

The source cluster was not shut down cleanly.
Failure, exiting
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES FAILED

Please visit https://meta.discourse.org/t/postgresql-13-update/172563 for support.

You can run ./launcher start app to restart your app in the meanwhile




FAILED
--------------------
Pups::ExecError: /root/upgrade_postgres failed with return #<Process::Status: pid 46 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "/root/upgrade_postgres"
c98d1b076faed9b0c728cd944b3f2436afc9e266910b82a644c71fd80b42f073
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
==================== END REBUILD LOG ====================
Failed to rebuild app.

Checking your domain name . . .

Connection to forum.kirupa.com succeeded.
You should probably remove any non-standard plugins and rebuild.
Attempting to restart existing container. . . 

starting up existing container
+ /usr/bin/docker start app
Error response from daemon: driver failed programming external connectivity on endpoint app (78a35e0f12e5af560bd1f991ead900fefd0c81570cc4582fe99aaa5e56b238e8): Error starting userland proxy: listen tcp 0.0.0.0:443: bind: address already in use
Error: failed to start containers: app
Failed to restart the container.


==================== PLUGINS ====================
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-sitemap.git

No non-official plugins detected.

See https://github.com/discourse/discourse/blob/master/lib/plugin/metadata.rb for the official list.

========================================
Discourse version at forum.kirupa.com: NOT FOUND
Discourse version at localhost: NOT FOUND

ما هي أفكارك حول ما يحدث هنا؟ استعادة المنتديات هي هدفي الأول. إصلاح فشل الترقيات هو هدفي الثاني.

شكرًا،
كيروبا

يجب أن تنظر إلى هنا - يبدو أن هذه هي نفس المشكلة: Help! Upgrade led to complete fail

كان لدي ما أعتقد أنه حالة مماثلة بالأمس (انظر Help! Upgrade led to complete fail - #8 by Judith). بشكل عام، أعتقد أنك تحتاج إلى القيام بشيء مثل:

  • إعادة تسمية postgres_data _old إلى postgres_data
  • إعادة تشغيل الحاوية القديمة
  • إصلاح مشكلة الفهرس التالف عن طريق إعادة تسمية المستخدمين المكررين (أو ربما المستخدمين المكررين لأن لديهم اختلافات في حالة الأحرف)
  • بناء الفهارس على جدول المستخدمين للتأكد من إصلاحها جميعًا
  • التبديل إلى قالب PostgreSQL 12 كما هو موصوف في تحديث PostgreSQL 13
  • إعادة البناء للترقية
  • عندما يعمل ذلك، يمكنك إعادة القالب إلى وضعه السابق وإكمال الترقية.
  • لاحظ أنك تحتاج إلى تحديث ليس فقط اسم المستخدم بل أيضًا username_lower

الحالة التي أصلحتها بالأمس كانت تحتوي على اسم مستخدم مكرر يعود إلى فبراير 2020، لذا من المرجح أنك لا ترغب في محاولة إصلاح ذلك عن طريق استعادة قاعدة بيانات أقدم.

لإصلاح المشكلة، تحتاج إلى فهم كيفية تعديل السجلات باستخدام سطر أوامر postgres، وإعادة بناء قواعد البيانات، والتعامل مع مشكلات معقدة لكنها موثقة جيدًا في تحديث postgres 13.

إذا كان لديك ميزانية قدرها 500 دولار، يمكنك التواصل معي. معلومات الاتصال الخاصة بي موجودة في ملفي الشخصي.

@pfaffman - لقد أرسلت لك رسالة عبر نموذج الاتصال الخاص بك :slight_smile:

أجبت. إذا لم تستلمها، فربما أدخلت العنوان الخاطئ؟

إعجاب واحد (1)

لإغلاق هذه الحلقة، فإن @pfaffman ساحر. لقد حل مشكلة ترقية المنتدى (وجملة من القضايا ذات الصلة) بسرعة فائقة :slight_smile:

3 إعجابات

أواجه نفس المشكلة، لكنني لن أدفع 500 دولار مقابل حل. لدي وصول SFTP إلى الخادم، لذا ألن يكون من الممكن فتح قاعدة البيانات في المفكرة وإعادة تسمية اسم المستخدم المتعارض؟

أو إذا كان بإمكان أي شخص إصلاحه مقابل 50 دولارًا تقريبًا، فيرجى الاتصال بي.

يمكنك الاطلاع على PG::UniqueViolation Problem during 3.1.0.beta4 upgrade - #3 by ahmedeldeep حيث وصف شخص ما ما فعله بشكل جيد جدًا.
ستحتاج إلى عميل SSH، وليس SFTP. إذا كنت تستخدم Digital Ocean، يمكنك استخدام وحدة التحكم على موقعهم على الويب.