Skip to content

Commit

Permalink
[BE] replica로 업데이트 쿼리 날아가던 오류 수정 (#374)
Browse files Browse the repository at this point in the history
hotfix: replica로 업데이트 쿼리 날아가던 오류 수정
  • Loading branch information
ikjo39 authored Sep 27, 2024
1 parent ea2ccdc commit 912b343
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backend/src/main/java/kr/momo/config/RoutingDataSource.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package kr.momo.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import org.springframework.transaction.support.TransactionSynchronizationManager;

public class RoutingDataSource extends AbstractRoutingDataSource {

private static final Logger log = LoggerFactory.getLogger(RoutingDataSource.class);

@Override
protected Object determineCurrentLookupKey() {
if (TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
return DataSourceConfig.REPLICA_SERVER;
}
return DataSourceConfig.SOURCE_SERVER;
boolean currentTransactionReadOnly = TransactionSynchronizationManager.isCurrentTransactionReadOnly();
String key = currentTransactionReadOnly ? DataSourceConfig.REPLICA_SERVER : DataSourceConfig.SOURCE_SERVER;
log.info("Activated Datasource: {}", key);
return key;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public List<String> findAll(String uuid) {
/**
* TEMP: 비밀번호 마이그레이션 이후 삭제될 메서드입니다.
*/
@Transactional
public Integer updateAllPassword() {
List<Attendee> attendees = attendeeRepository.findAll();
List<Attendee> rawAttendees = attendees.stream()
Expand Down

0 comments on commit 912b343

Please sign in to comment.