Comments (7)
That sounds correct, and would explain some issues we've seen. @mertalev thoughts?
from immich.
It does (or should I guess) check if it should update the smart search table at startup. Specifically, it checks if the dimensions of the current model match the dimensions in the table and updates the table if not. It's possible there's a bug somewhere in that logic, though.
from immich.
Apologies if I'm completely off on the wrong path, I don't know typescript at all or Javascript basically at all, but in the codebase I'm seeing the following control flow:
(inside the server
section of the repo, and converting from the JS files on my drive to the TS files in the repo)
start.sh
runs node
on main
-> src/main.js
runs nestFactory.create() on apiModule
-> src/app.module.ts
constructor of ApiModule calls the init() of an ApiService -> src/services/api.service.ts
calls init() on a databaseService -> src/services/database.service.ts
At this point, the following seems to occur:
- if the postgres version is below the minimum major version, the code throws an error (14 is hardcoded as the minimum earlier in the file)
- Attempts to lock the database with a lock of 'Databaselock.Migrations`
- if this fails for some reason, nothing happens
- If the lock succeeds:
- Runs
createVectorExtension()
->src/repositories/database.repository.ts
runs a query ofCREATE EXTENSION IF NOT EXISTS ${extension}
where ${extension} is the preferred extension of vectors and vector. if this fails, an error is thrown - Runs
updateVectorExtension()
->src/repositories/database.repository.ts
- Compares the vector extension version to the expected one
- If the version is outdated and the extension is vectors
- Runs
updateVectorSchema
if the version is outdated
- Runs
- Runs a query setting the version of the extension to the expected one
- if the version was not outdated, at this point it returns (note: it does not return an explicit value and I do not know what the default is in typescript?)
- if the version WAS outdated
- if the extension is vectors, run
SELECT pgvectors_upgrade()
and set "restartRequired" to TRUE - if the extension IS NOT vectors, run a reindex of FACE and CLIP indexes
- At this point in the codepath, it seems to be updating the 'embeddings' column with a new dimSize
- to get here, the extension would have to be "vector" (not "vectors") and an update had to happen
- if the extension is vectors, run
- Runs
assertVectorExtension()
which just throws an error if the extension version is null, presumably as a final check that the above at least ~somewhat happened correctly.
- Runs
Taking a brief break from bullet points to refocus: at this point we're at Line 36 of the database.service.ts file. At this point, the following happens:
shouldReindex
is checked for each of FACE and CLIP ->src/repositories/database.repository.ts
- if the extension isn't "vectors" it returns false immediately
- if the extension IS "vectors", it runs
SELECT idx_status FROM pg_vector_index_stat WHERE indexname
for either FACE or CLIP- If the idx_status is "UPGRADE", it returns TRUE
- if the idx_status is anything else, it returns FALSE
- on error, if the response includes the words 'index is not existing', it returns TRUE
- on error if the response includes the words 'relation "pg_vector_index_stat" does not exist', it returns FALSE
- otherwise it throws the error
- NOTE: this query returns
NORMAL
in my database for both items, so it would return FALSE
I am probably missing some sort of invalid state
detail here. Maybe it's impossible to have it get to the end without it running this reindex at least once? But as I'm looking at it, it only gets to the point of running the reindex
code (which is the code that does the dimSize column update) when an update to the vector extension was needed, which presumably never occurred here because this was a new install of an (idempotently-deployed) current version of the pgvecto.rs tensorchord container image.
from immich.
The check happens in the search repository's init, referenced in the smart info service.
from immich.
Oh, I guess the init in the smart info service isn't getting called anywhere haha.
from immich.
Ah, so itβs just not calling that unless you change the model while running?
from immich.
Yup, so it only updates on a config change event in practice. Making it run at startup should fix it.
from immich.
Related Issues (20)
- Upload via Domain -> Cloudflare is crashing HOT 1
- [BUG] Timeline endpoint returns the wrong video duration HOT 2
- IOS App - Downloading Image from Immich that is marked as Favourite, does not reflect in Apple Photos
- Issue with navbar in Android
- I would like to try translating immich's web application into Chinese HOT 5
- Photos from external library do not show in iOS app HOT 3
- Auto Backup Logic bug
- Search by camera looks bad in Android
- Android app freezing after launch HOT 2
- Moving a picture in the trash doesn't change the photo album's or location album's thumbnail.
- External Library Non-existent path file was accidentally deleted. HOT 2
- VAAPI AV1 encoding not supported HOT 1
- RAW (NEF) Files from Raw + Jpeg shooting stored at a different time/date than the Jpeg
- External Library - Permissions Denied on NFS shares, and mkdir on existing folders
- Transcoding gets blocked on certain videos creating multiple instances of ffmpeg running HOT 10
- iOS app showing what looks like an XML file on "advanced info" instead of nicely formatted information HOT 2
- Slideshow has problems loading images after running for a while HOT 1
- Some photos are treated as motion photos, even though they don't appear to be such
- Not everything is uploaded from the Android App HOT 2
- App Android and IOS: Deleted pictures are still shown in full view after deletion swiping left
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immich.