fix: chain dropIndex before createIndex on ap_muted to prevent race condition
The non-async init() fired dropIndex and createIndex concurrently, causing MongoDB to abort the index build (IndexBuildAborted error 276). Chain createIndex via .then() so it runs after the drop completes. Confab-Link: http://localhost:8080/sessions/e9d666ac-3c90-4298-9e92-9ac9d142bc06
This commit is contained in:
@@ -1000,18 +1000,27 @@ export default class ActivityPubEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop non-sparse indexes if they exist (created by earlier versions),
|
// Muted collection — sparse unique indexes (allow multiple null values)
|
||||||
// then recreate with sparse:true so multiple null values are allowed.
|
this._collections.ap_muted
|
||||||
this._collections.ap_muted.dropIndex("url_1").catch(() => {});
|
.dropIndex("url_1")
|
||||||
this._collections.ap_muted.dropIndex("keyword_1").catch(() => {});
|
.catch(() => {})
|
||||||
this._collections.ap_muted.createIndex(
|
.then(() =>
|
||||||
{ url: 1 },
|
this._collections.ap_muted.createIndex(
|
||||||
{ unique: true, sparse: true, background: true },
|
{ url: 1 },
|
||||||
);
|
{ unique: true, sparse: true, background: true },
|
||||||
this._collections.ap_muted.createIndex(
|
),
|
||||||
{ keyword: 1 },
|
)
|
||||||
{ unique: true, sparse: true, background: true },
|
.catch(() => {});
|
||||||
);
|
this._collections.ap_muted
|
||||||
|
.dropIndex("keyword_1")
|
||||||
|
.catch(() => {})
|
||||||
|
.then(() =>
|
||||||
|
this._collections.ap_muted.createIndex(
|
||||||
|
{ keyword: 1 },
|
||||||
|
{ unique: true, sparse: true, background: true },
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.catch(() => {});
|
||||||
|
|
||||||
this._collections.ap_blocked.createIndex(
|
this._collections.ap_blocked.createIndex(
|
||||||
{ url: 1 },
|
{ url: 1 },
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rmdes/indiekit-endpoint-activitypub",
|
"name": "@rmdes/indiekit-endpoint-activitypub",
|
||||||
"version": "2.4.0",
|
"version": "2.4.1",
|
||||||
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"indiekit",
|
"indiekit",
|
||||||
|
|||||||
Reference in New Issue
Block a user