axfelix
(Alex Garnett)
3 Maggio 2022, 3:34pm
1
Si è verificato un errore nella ricostruzione automatica, sembra che ci siano variazioni su questo problema:
2022-05-03 15:30:54.370 UTC [1262] discourse@discourse LOG: duration: 1707.909 ms statement: INSERT INTO post_hotlinked_media (post_id, url, status, upload_id, created_at, updated_at)
SELECT
post_id,
obj.key AS url,
'downloaded',
obj.value::bigint AS upload_id,
pcf.created_at,
pcf.updated_at
FROM post_custom_fields pcf
JOIN json_each_text(pcf.value::json) obj ON true
JOIN uploads ON obj.value::bigint = uploads.id
WHERE name='downloaded_images'
ERROR: duplicate key value violates unique constraint \"index_post_hotlinked_media_on_post_id_and_url_md5\"
Ho ricostruito meno di un mese fa senza errori, quindi qualunque cosa abbia introdotto questo problema sembra essere recente.
4 Mi Piace
axfelix
(Alex Garnett)
3 Maggio 2022, 4:09pm
3
sembra che abbia a che fare con questo recente commit?
# frozen_string_literal: true
class CreatePostHotlinkedMedia < ActiveRecord::Migration[6.1]
def change
reversible do |dir|
dir.up do
execute <<~SQL
CREATE TYPE hotlinked_media_status AS ENUM('downloaded', 'too_large', 'download_failed', 'upload_create_failed')
SQL
end
dir.down do
execute <<~SQL
DROP TYPE hotlinked_media_status
SQL
end
end
create_table :post_hotlinked_media do |t|
t.bigint :post_id, null: false
t.string :url, null: false
This file has been truncated. show original
@david
2 Mi Piace
david
(David Taylor)
3 Maggio 2022, 4:15pm
4
Sì, è così. Ho una correzione in lavorazione, dovrebbe essere unita nei prossimi minuti. Grazie per la segnalazione @axfelix
main ← hotlinked-conflict
opened 03:54PM - 03 May 22 UTC
In the old custom_field-based system, it was possible for a url to be both 'down… loaded' and 'broken'. The new table enforces uniqueness, so we need to drop invalid data.
9 Mi Piace
axfelix
(Alex Garnett)
3 Maggio 2022, 4:39pm
5
Grazie, è stato veloce!
Devo fare qualcosa di speciale per scaricarlo? Ricevo ancora Caused by:\nActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint \"index_post_hotlinked_media_on_post_id_and_url_md5\" durante l’esecuzione di una ricostruzione del launcher, anche dopo aver eseguito un Docker prune.
david
(David Taylor)
3 Maggio 2022, 4:48pm
6
La correzione è appena passata ai test-passed pochi secondi fa. Se ricostruisci ora, dovrebbe funzionare molto meglio. Facci sapere come va.
5 Mi Piace
david
(David Taylor)
3 Maggio 2022, 6:07pm
7
Abbiamo trovato un altro posto che potrebbe causare questo errore. Quindi, se la prima correzione non ha aiutato, questa dovrebbe:
committed 05:51PM - 03 May 22 UTC
custom_field data on some sites has duplicate values for a given url key in the … JSON value. This is invalid, so we should drop the extra data.
(ora attivo in tests-passed)
4 Mi Piace
pfaffman
(Jay Pfaffman)
3 Maggio 2022, 7:31pm
8
Nella mia istanza di sviluppo esegue correttamente la migrazione del database, ma se ripristino un backup da 2022-04-27-153103-v20220407195246.tar.gz fallisce:
[361/9020]
Migrating the database... EXCEPTION: /home/pfaffman/src/discourse-repos/discourse/lib/discourse.rb:126:in `exec': Failed to migrat
e database.
Ignoring /home/pfaffman/src/discourse-repos/discourse/db/schema_cache.yml because it has expired. The cu
rrent schema version is 20220407195246, but the one in the schema cache file is 20220428094027.
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
seguito da altro di quel tipo con alcuni di questi:
ActiveRecord::StatementInvalid: PG::DuplicateObject: ERROR: type \"hotlinked_media_status\" already exist
1 Mi Piace
axfelix
(Alex Garnett)
3 Maggio 2022, 9:22pm
9
Solo per dire che la prima correzione ha funzionato per noi dopo aver superato i test!
2 Mi Piace
david
(David Taylor)
3 Maggio 2022, 9:30pm
10
Ottimo, grazie per la conferma!
Ho aperto una PR con una correzione per quello:
main ← fix-restore-enums
opened 09:27PM - 03 May 22 UTC
c1db9687 introduced an postgres enum type. Our database restore logic did not ha… ndle custom types correctly, and would therefore raise a 'type already exists' error when restoring any backup.
This commit adds restore handling for enums, mirroring the similar logic for tables and views.
---
(This code is not tested by rspec, but it is tested by a regular internal job at CDCK, which correctly picked up on this issue)
4 Mi Piace
pfaffman
(Jay Pfaffman)
4 Maggio 2022, 2:05pm
11
Finito!
[SUCCESSO]
Ripristino completato.
Grazie!
2 Mi Piace