mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Merge branch 'pipeline-stats' into 'main'
pipeline: insert event even if stats fail Closes #221 and #227 See merge request soapbox-pub/ditto!517
This commit is contained in:
commit
be88e0bc2e
1 changed files with 14 additions and 4 deletions
|
|
@ -135,10 +135,20 @@ async function storeEvent(event: DittoEvent, signal?: AbortSignal): Promise<unde
|
|||
if (NKinds.ephemeral(event.kind)) return;
|
||||
const store = await Storages.db();
|
||||
|
||||
await store.transaction(async (store, kysely) => {
|
||||
await updateStats({ event, store, kysely }).catch((e) => console.error(e));
|
||||
await store.event(event, { signal });
|
||||
});
|
||||
try {
|
||||
await store.transaction(async (store, kysely) => {
|
||||
await updateStats({ event, store, kysely });
|
||||
await store.event(event, { signal });
|
||||
});
|
||||
} catch (e) {
|
||||
// If the failure is only because of updateStats (which runs first), insert the event anyway.
|
||||
// We can't catch this in the transaction because the error aborts the transaction on the Postgres side.
|
||||
if (e instanceof Error && e.message.includes('event_stats' satisfies keyof DittoTables)) {
|
||||
await store.event(event, { signal });
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Parse kind 0 metadata and track indexes in the database. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue