Skip to content

Commit

Permalink
๐Ÿš‘ !HOTFIX: ํŠธ๋žœ์žญ์…˜ ๊ฒฉ๋ฆฌ ์ˆ˜์ค€ ์ œ๊ฑฐ ๋ฐ pessimistic write ์ถ”๊ฐ€
Browse files Browse the repository at this point in the history
  • Loading branch information
sieunie committed Nov 28, 2024
1 parent 74df95d commit 2b7526a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion BE/src/stockSocket/stock-execute-order.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class StockExecuteOrderRepository extends Repository<Order> {

async checkExecutableOrder(stockCode, value) {
const queryRunner = this.dataSource.createQueryRunner();
await queryRunner.startTransaction('SERIALIZABLE');
await queryRunner.startTransaction();

try {
const buyOrders = await queryRunner.manager.find(Order, {
Expand All @@ -39,6 +39,9 @@ export class StockExecuteOrderRepository extends Repository<Order> {
status: StatusType.PENDING,
price: MoreThanOrEqual(value),
},
lock: {
mode: 'pessimistic_write',
},
});

const sellOrders = await queryRunner.manager.find(Order, {
Expand All @@ -48,6 +51,9 @@ export class StockExecuteOrderRepository extends Repository<Order> {
status: StatusType.PENDING,
price: LessThanOrEqual(value),
},
lock: {
mode: 'pessimistic_write',
},
});

await Promise.all(
Expand Down

0 comments on commit 2b7526a

Please sign in to comment.