Skip to content

Commit 29346f0

Browse files
committed
sentry - db - accounting - spend_amount:
Remove transaction because of the isolation level that might casue loss of events
1 parent 2ba6dcd commit 29346f0

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

sentry/src/db/accounting.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,9 @@ pub async fn spend_amount(
131131
channel_id: ChannelId,
132132
delta_balances: Balances<CheckedState>,
133133
) -> Result<(Vec<Accounting>, Vec<Accounting>), PoolError> {
134-
let mut client = pool.get().await?;
135-
136-
// The reads and writes in this transaction must be able to be committed as an atomic “unit” with respect to reads and writes of all other concurrent serializable transactions without interleaving.
137-
let transaction = client
138-
.build_transaction()
139-
.isolation_level(IsolationLevel::Serializable)
140-
.start()
141-
.await?;
134+
let client = pool.get().await?;
142135

143-
let statement = transaction.prepare(UPDATE_ACCOUNTING_STATEMENT).await?;
136+
let statement = client.prepare(UPDATE_ACCOUNTING_STATEMENT).await?;
144137

145138
let now = Utc::now();
146139
let updated: Option<DateTime<Utc>> = None;
@@ -149,7 +142,7 @@ pub async fn spend_amount(
149142

150143
// Earners
151144
for (earner, amount) in delta_balances.earners {
152-
let row = transaction
145+
let row = client
153146
.query_one(
154147
&statement,
155148
&[&channel_id, &Side::Earner, &earner, &amount, &updated, &now],
@@ -161,7 +154,7 @@ pub async fn spend_amount(
161154

162155
// Spenders
163156
for (spender, amount) in delta_balances.spenders {
164-
let row = transaction
157+
let row = client
165158
.query_one(
166159
&statement,
167160
&[
@@ -178,8 +171,6 @@ pub async fn spend_amount(
178171
spenders.push(Accounting::from(&row))
179172
}
180173

181-
transaction.commit().await?;
182-
183174
Ok((earners, spenders))
184175
}
185176

0 commit comments

Comments
 (0)