mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
stats: use the NPostgres transaction method to avoid transactions within transactions
This commit is contained in:
parent
55ee8eaf74
commit
d67f2a27ea
2 changed files with 5 additions and 2 deletions
|
|
@ -117,9 +117,8 @@ async function hydrateEvent(event: DittoEvent, signal: AbortSignal): Promise<voi
|
||||||
async function storeEvent(event: DittoEvent, signal?: AbortSignal): Promise<undefined> {
|
async function storeEvent(event: DittoEvent, signal?: AbortSignal): Promise<undefined> {
|
||||||
if (NKinds.ephemeral(event.kind)) return;
|
if (NKinds.ephemeral(event.kind)) return;
|
||||||
const store = await Storages.db();
|
const store = await Storages.db();
|
||||||
const kysely = await Storages.kysely();
|
|
||||||
|
|
||||||
await kysely.transaction().execute(async (kysely) => {
|
await store.transaction(async (store, kysely) => {
|
||||||
await updateStats({ event, store, kysely });
|
await updateStats({ event, store, kysely });
|
||||||
await store.event(event, { signal });
|
await store.event(event, { signal });
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,10 @@ class EventsDB implements NStore {
|
||||||
|
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async transaction(callback: (store: NPostgres, kysely: Kysely<DittoTables>) => Promise<void>): Promise<void> {
|
||||||
|
return this.store.transaction((store, kysely) => callback(store, kysely as unknown as Kysely<DittoTables>));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { EventsDB };
|
export { EventsDB };
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue