You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It turned out that currently the process of recomputing the label values is quite tricky and it involves some procedure and triggers to compute the dataset_view which is the one showed when filtering datasets.
DELETE FROM dataset_view WHERE dataset_id = NEW.dataset_id AND (NEW.view_id IS NULL OR NEW.view_id = view_id);
WITH view_agg AS (
SELECT vc.view_id, vc.id as vcid, array_agg(DISTINCT label.id) as label_ids, jsonb_object_agg(label.name, lv.value) as value FROM dataset_schemas ds
JOIN label ON label.schema_id = ds.schema_id
JOIN viewcomponent vc ON vc.labels ? label.name
JOIN label_values lv ON lv.label_id = label.id AND lv.dataset_id = ds.dataset_id
WHERE ds.dataset_id = NEW.dataset_id
AND (NEW.view_id IS NULL OR NEW.view_id = vc.view_id)
AND vc.view_id IN (SELECT view.id FROM view JOIN dataset ON view.test_id = dataset.testid WHERE dataset.id = NEW.dataset_id)
GROUP BY vc.view_id, vcid
) INSERT INTO dataset_view (dataset_id, view_id, label_ids, value)
SELECT NEW.dataset_id, view_id, array_agg(DISTINCT label_id), jsonb_object_agg(vcid, value) FROM view_agg, unnest(label_ids) as label_id
GROUP BY view_id;
To Reproduce
Startup Horreum
Create datasets and some views
Drop trigger from db drop trigger recalc_dataset_view on view_recalc_queue
Force datasets recalculation
In the dataset view filter by label value
Additional Notes
Why was it working before? My guess is that it was working by luck.. as the calc_dataset_view was inserting wrong data that was later overridden by recalc_dataset_view
Starting from 0.16 we removed the recalculation lock and we might have increased the concurrency level that may not gurantee the previous order (just a guess this)
The issue was present also before 0.16, we have been just lucky that we did not experience it
The text was updated successfully, but these errors were encountered:
Describe the bug
It turned out that currently the process of recomputing the label values is quite tricky and it involves some procedure and triggers to compute the
dataset_view
which is the one showed when filtering datasets.As you can see we are triggering both
calc_dataset_views
andrecalc_dataset_view
in an unpredictable order.The problem is that
calc_dataset_views
is wrong and it can compute wrong data.Horreum/horreum-backend/src/main/resources/db/changeLog.xml
Lines 4321 to 4334 in a763314
It is joining
label_values
without adding theon
condition withlv.dataset_id = ds.dataset_id
as therecalc_dataset_view
is doing.Horreum/horreum-backend/src/main/resources/db/changeLog.xml
Lines 3721 to 3736 in a763314
To Reproduce
drop trigger recalc_dataset_view on view_recalc_queue
Additional Notes
calc_dataset_view
was inserting wrong data that was later overridden byrecalc_dataset_view
The text was updated successfully, but these errors were encountered: