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
Fix deduplication of mags/attachments to scan for storage (#8981)
This PR is a follow up fix for #8789. The problem with #8789 is that it
allowed mags to be measured for storage amount multiple times if used
across multiple times across multipe organizations. This PR fixes the
logical bug in the sql query. Same goes for attachments.
### URL of deployed dev instance (used for testing):
- https://___.webknossos.xyz
### Steps to test:
- I suggest to test locally.
- On master: Create a new orga (e.g. via `isWkOrgInstance=true` in
`application.conf`);
- also reduce `fetchUsedStorage` time in `application.conf`. e.g.
`rescanInterval = 30 seconds` `tickerInterval = 10 seconds`
- Symlink a dataset from the sample_organization into the new orga
- Trigger a dataset rescan in the new orga
- The symlinked dataset's mags should now appear in
```
SELECT * FROM (SELECT COUNT(*) AS count, COALESCE(realPath, path) as ppath FROM webknossos.dataset_mags
GROUP BY ppath) WHERE count > 1
```
- Check the `webknossos.organization_usedstorage_mags` table. It should
list duplicate measurements for the mag paths of the symlinked dataset.
```
SELECT * FROM (SELECT COUNT(*) AS count, path FROM webknossos.organization_usedstorage_mags
GROUP BY path) WHERE count > 1
```
- Now checkout this branch. !Do not refresh the schema!
- Run this branch's evolution
- Wait a bit for the storage rescan and check the
`organization_usedstorage_mags` table again. There should no longer be
duplicates. The following query's set should be empty now
```
SELECT * FROM (SELECT COUNT(*) AS count, path FROM webknossos.organization_usedstorage_mags
GROUP BY path) WHERE count > 1
```
### Issues:
- fixes https://scm.slack.com/archives/C5AKLAV0B/p1759761569291259;
follow up for #8789
------
(Please delete unneeded items, merge only when none are left open)
- [x] Added changelog entry (create a `$PR_NUMBER.md` file in
`unreleased_changes` or use `./tools/create-changelog-entry.py`)
- [x] Added migration guide entry if applicable (edit the same file as
for the changelog)
- [x] Needs datastore update after deployment
---------
Co-authored-by: Florian M <[email protected]>
do $$ begin if (select schemaVersion fromwebknossos.releaseInformation) <>143 then raise exception 'Previous schema version mismatch'; end if; end; $$ language plpgsql;
do $$ begin if (select schemaVersion fromwebknossos.releaseInformation) <>144 then raise exception 'Previous schema version mismatch'; end if; end; $$ language plpgsql;
4
+
5
+
DROPINDEX IF EXISTS webknossos.dataset_mags_coalesce_idx;
6
+
DROPINDEX IF EXISTS webknossos.dataset_layer_attachments_path_idx;
0 commit comments