Rasin
(Rasin)
2019 年10 月 16 日 06:38
1
我尝试将备份恢复到新服务器时,出现了一些错误。
日志在此:Ubuntu Pastebin
错误可能是:
PG::UniqueViolation: ERROR: could not create unique index "unique_index_categories_on_slug"
DETAIL: Key (COALESCE(parent_category_id, '-1'::integer), slug)=(5, ) is duplicated.
我原本以为这是数据库问题,但我并没有修改过数据库。只是下载了备份的 tar 包,但恢复过程出错了。
请帮忙!
ariznaf
(fernando)
2019 年10 月 16 日 07:02
2
还有一个线程讨论了类似的问题。
这是一个很奇怪的问题。
我们中的许多人通过不断尝试解决了它。
请多试几次,也许其中一次就不会再出现错误。
可能你的问题有所不同,但它与我们在恢复过程中遇到的数据库错误相似。
这似乎是恢复脚本中存在一个 bug,或者是所使用的 PostgreSQL 数据库系统存在某种类型的 bug。
Rasin
(Rasin)
2019 年10 月 16 日 07:12
3
这个解决方案真是奇怪……FML
能不能编辑一下 SQL 文件,让它恢复正常?
我的意思是,有没有办法忽略重复的键?
Rasin
(Rasin)
2019 年10 月 16 日 07:57
4
在我回退到之前的版本或测试版后,日志显示如下:
EXCEPTION: Compression::Strategy::ExtractFailed[2019-10-16 07:53:52] /var/www/discourse/lib/compression/strategy.rb:89:in `block in extract_file'
/var/www/discourse/lib/compression/strategy.rb:85:in `open'
/var/www/discourse/lib/compression/strategy.rb:85:in `extract_file'
/var/www/discourse/lib/compression/strategy.rb:26:in `block (2 levels) in decompress'
/usr/local/lib/ruby/site_ruby/2.6.0/rubygems/package/tar_reader.rb:65:in `each'
/var/www/discourse/lib/compression/strategy.rb:18:in `block in decompress'
/var/www/discourse/lib/compression/tar.rb:26:in `get_compressed_file_stream'
/var/www/discourse/lib/compression/strategy.rb:15:in `decompress'
/var/www/discourse/lib/compression/pipeline.rb:26:in `block in decompress'
/var/www/discourse/lib/compression/pipeline.rb:24:in `each'
/var/www/discourse/lib/compression/pipeline.rb:24:in `reduce'
/var/www/discourse/lib/compression/pipeline.rb:24:in `decompress'
/var/www/discourse/lib/backup_restore/restorer.rb:141:in `decompress_archive'
/var/www/discourse/lib/backup_restore/restorer.rb:60:in `run'
/var/www/discourse/lib/backup_restore.rb:166:in `block in start!'
/var/www/discourse/lib/backup_restore.rb:163:in `fork'
/var/www/discourse/lib/backup_restore.rb:163:in `start!'
/var/www/discourse/lib/backup_restore.rb:22:in `restore!'
/var/www/discourse/app/controllers/admin/backups_controller.rb:119:in `restore'
这为什么是个问题?我并没有对 tar 文件做任何修改。
Rasin
(Rasin)
2019 年10 月 16 日 12:46
6
非常感谢你在这个提取工作上的帮助!
你能帮我解决键重复的错误吗?或者有没有办法在 psql 中修复这个 SQL?
gerhard
(Gerhard Schlager)
2019 年10 月 16 日 13:39
7
Rasin:
错误可能是:
PG::UniqueViolation: ERROR: 无法创建唯一索引 "unique_index_categories_on_slug"
DETAIL: 键 (COALESCE(parent_category_id, '-1'::integer), slug)=(5, ) 已重复。
@daniel 我认为 FIX: Add unique index to prevent duplicate slugs for categories · discourse/discourse@c71da3f · GitHub 中的迁移需要在创建唯一索引之前确保列值的唯一性。
daniel
(Daniel Waterworth)
2019 年10 月 16 日 14:36
8
@Rasin ,此问题现已修复,修复提交如下:
committed 02:02PM - 16 Oct 19 UTC
Slugs can be the empty string, but the added index didn't account for
that. This… commit changes the migration, stopping it from being unique
so that it can be applied everywhere and adds another migration that
recreates the index properly.
感谢您提醒我们此事,对于造成的任何不便我们深表歉意。如果您遇到其他问题,请随时告知我们。
ariznaf
(fernando)
2019 年10 月 16 日 21:52
9
是的,我已经告诉过你:这确实很奇怪。
但它对我们中的几个人奏效了,你可以从这里读到:
Wow, trying to reproduce it so I can be sure that things will go as planned on migration, and I have the error again? I’m going to continue to try and find the steps to reproduce a fix. Because I can’t reproduce it now.
我不知道你的情况是否相同,因为错误相似但并不完全一样。
@usulrasolas 评论说他通过编辑脚本并添加 SQL 语句来修正了问题。
但我和其他人都没有做任何更改,只是尝试了多次。
这确实很奇怪,我知道,但可能涉及时间或超时问题。
我们还不清楚具体情况。
开发人员正在调查此事。