Incremental search indexing (#6453)

* wip: initial kafka support

* wip: kafka search queue

* wip: kafka consumer

* wip: create/delete docs

* reindexing works

* reindex in more places

* also incrementally update server pings

* cleanup

* tombi

* fix ci

* update tombi

* prepare

* fix ci

* fix

* fix PLEASE

* 🙏

* add route to force reindex project
This commit is contained in:
aecsocket
2026-06-21 10:03:20 +00:00
committed by GitHub
parent be65589e4d
commit c6ef10e798
53 changed files with 1212 additions and 164 deletions
+10 -8
View File
@@ -24,11 +24,13 @@ async fn set_project_processing(
pool: &labrinth::database::PgPool,
redis: &labrinth::database::redis::RedisPool,
) {
sqlx::query("UPDATE mods SET status = 'processing' WHERE id = $1")
.bind(project_id)
.execute(pool)
.await
.expect("failed to set project to processing status");
sqlx::query!(
"UPDATE mods SET status = 'processing' WHERE id = $1",
project_id
)
.execute(pool)
.await
.expect("failed to set project to processing status");
DBProject::clear_cache(
DBProjectId(project_id),
@@ -42,11 +44,11 @@ async fn set_project_processing(
/// Back-date a lock's `locked_at` so it appears expired.
async fn expire_lock(project_id: i64, pool: &labrinth::database::PgPool) {
sqlx::query(
sqlx::query!(
"UPDATE moderation_locks SET locked_at = NOW() - ($1::bigint * INTERVAL '1 minute') - INTERVAL '1 second' WHERE project_id = $2",
LOCK_EXPIRY_MINUTES,
project_id,
)
.bind(LOCK_EXPIRY_MINUTES)
.bind(project_id)
.execute(pool)
.await
.expect("failed to expire lock");
+6 -6
View File
@@ -25,7 +25,7 @@ pub async fn search_users_returns_compact_prefix_matches_with_exact_first() {
with_test_environment(
None,
|test_env: TestEnvironment<ApiV3>| async move {
sqlx::query(
sqlx::query!(
"
INSERT INTO users (id, username, email, role)
VALUES
@@ -65,21 +65,21 @@ pub async fn search_users_escapes_wildcards_and_limits_results() {
None,
|test_env: TestEnvironment<ApiV3>| async move {
for i in 0..30 {
sqlx::query(
sqlx::query!(
"
INSERT INTO users (id, username, email, role)
VALUES ($1, $2, $3, 'developer')
",
2000 + i,
format!("prefix{i:02}"),
format!("prefix{i:02}@modrinth.com"),
)
.bind(2000 + i)
.bind(format!("prefix{i:02}"))
.bind(format!("prefix{i:02}@modrinth.com"))
.execute(&*test_env.db.pool)
.await
.unwrap();
}
sqlx::query(
sqlx::query!(
"
INSERT INTO users (id, username, email, role)
VALUES (2100, 'prefix_under_score', 'prefix_under_score@modrinth.com', 'developer')