Skip to content

High performance self-hosted photo and video management solution.

fix(server): deadlock when fetching vector count (#18728)

Mertbe247395dbc5
diff --git a/server/src/repositories/database.repository.ts b/server/src/repositories/database.repository.ts
index 1e8e147c43..94d9029f60 100644
--- a/server/src/repositories/database.repository.ts
+++ b/server/src/repositories/database.repository.ts
@@ -246,6 +246,7 @@ export class DatabaseRepository {
return;
}
const dimSize = await this.getDimensionSize(table);
+ lists ||= this.targetListCount(await this.getRowCount(table));
await this.db.schema.dropIndex(indexName).ifExists().execute();
if (table === 'smart_search') {
await this.db.schema.alterTable(table).dropConstraint('dim_size_constraint').ifExists().execute();
@@ -262,7 +263,6 @@ export class DatabaseRepository {
ALTER TABLE ${sql.raw(table)}
ALTER COLUMN embedding
SET DATA TYPE ${sql.raw(schema)}vector(${sql.raw(String(dimSize))})`.execute(tx);
- lists ||= this.targetListCount(await this.getRowCount(table));
await sql.raw(vectorIndexQuery({ vectorExtension, table, indexName, lists })).execute(tx);
});
try {