mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
fix: rollback to savepoint if updateStats() function fails
This commit is contained in:
parent
d72ec843cf
commit
a7074c5c9e
1 changed files with 6 additions and 1 deletions
|
|
@ -136,7 +136,12 @@ async function storeEvent(event: DittoEvent, signal?: AbortSignal): Promise<unde
|
|||
const store = await Storages.db();
|
||||
|
||||
await store.transaction(async (store, kysely) => {
|
||||
await updateStats({ event, store, kysely }).catch((e) => console.error(e));
|
||||
await sql`SAVEPOINT update_stats_savepoint`.execute(kysely);
|
||||
|
||||
await updateStats({ event, store, kysely }).catch(async (e) => {
|
||||
await sql`ROLLBACK TO SAVEPOINT update_stats_savepoint`.execute(kysely);
|
||||
console.error(e);
|
||||
});
|
||||
await store.event(event, { signal });
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue