전체 글
-
yum update와 OOM인프라/linux 2024. 4. 18. 20:49
RHEL 9.3 버전에서 snapd를 설치하는 중 만난 이슈를 해결하는 과정을 정리합니다. 1. 이슈 원인 파악 snapd를 설치하기 위해서 다음과 같은 명령어를 호출했습니다. $ sudo yum install install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm $ sudo yum update 보통은 조금 기다리면 설치가 진행이 되는데 killed가 되었다고 합니다. GPT에게 물어보니 메모리 부족은 아닐지 찾아보라고 합니다 OOM에 관련된 로그가 있는지 살펴보러 갑니다. $ sudo cat /var/log/messages 낮익은 로그들이 있습니다. OOM Killer에 의해 프로세스가 정리되었다고 하는군요. 2. ..
-
Swapfile은 무엇이길래 메모리 부족을 해결해주는가?인프라/linux 2024. 4. 18. 20:45
EC2 프리티어를 사용하다 보니 메모리 부족을 종종 만나게 됩니다. 사실은.. 이 상황을 만날 때마다 찾아보는 것에 지쳐서 적어두려고 합니다. [ 공식문서 ] 스왑파일 설정하는 김에 스왑파일이 무엇인지도 한번 짚어봅니다. 1. Swapfile은 무엇이길래 메모리 부족을 해결해주는가? 아주 간단하게 이야기하면 메모리에 빈 자리가 없을 때 안 쓰이는 대상을 잠깐 치워두는 공간 정도로 설명할 수 있을 것 같습니다. 아래에 제가 이해하고 있는 메모리와 swapfile의 사용을 간단하게 도식화 해두었습니다. 2. Swapfile 할당하기 스웹 파일은 전통적으로 메모리의 2배를 사용하는 것을 권장한다고 하는 듯 합니다. 실수로 4배를 할당한 김에, 잘못 할당된 것을 정리하고 다시 할당하는 과정을 해보겠습니다 ㅎㅎ ..
-
useEffect가 2번 실행된다면 ( ft. StrictMode )프레임워크/Nextjs 2024. 4. 18. 18:38
여유있게 시간을 가지고 공부하면서 가장 즐거운 부분은 문제가 생겼을 때, 천천히 공식문서를 음미할 수 있다는 부분이 아닌가 합니다 ㅎㅎ 이번 글은 게시글을 조회하면서 조회수가 2개씩 오르는 것을 디버깅하다가 발견하여 적어봅니다. 이 글은 다음과 같은 순서로 진행됩니다. 1. 문제를 확인 2. 원인 파악 및 해결 3. StrictMode는 무엇? 1. 문제를 확인 분명히 클릭이 한번만 발생하는데 useEffect가 두번씩 동작합니다. 디펜던시가 뭐가 걸려있나 확인해봤는데, 빈 배열입니다. 뭔일인가 싶어서, 바로 GPT에게 물어보니 Strict Mode라는 키워드를 던져줍니다. 2. 원인 파악 및 해결 리액트로 작업할 때는 보통 벗겨내고 작업을 해와서 크게 인지하지 않고 있었는데, Next에서도 Strict..
-
모듈 간의 데이터 통신은 어떻게 하는게 좋을까OFF THE RECORD/생각 2024. 4. 17. 21:08
갑작스럽게 react-native-webview를 기반으로 Nextjs 웹앱을 띄우는 프로젝트에 참여하면서 느낀 것이 많아 글로 남겨봅니다. RN과 Nextjs가 서로 데이터를 주고 받음에 있어서 어떻게 하면 더 관리하기 용이할까 하는 측면에서 글을 써보겠습니다. 글은 다음과 같이 구성되어 있습니다. 1. 통신 채널의 형태 2. 두 모듈 간의 관계 3. 절대 놓치면 안된다고 느낀 부분 1. 통신 채널의 형태 1-1. 기존 설계 React-native 개발자로 근무하면서 앱이 메인이고 부수적인 작업들만 webview를 사용해서 처리했기 때문에, 크게 설계적인 측면은 고려하지 않고 작업해왔던 것 같습니다. 그러던 중 이번 프로젝트에서 양방향 메세지 큐를 생각나게 하는 설계가 되어있어서 흥미롭게 살펴보았습니다..
-
내부에서 실행되는 메소드에 인자가 잘 전달되는지 테스트프레임워크/JUnit 2024. 4. 17. 02:09
이번 글은 스프링 부트 프로젝트에서 컨트롤러를 테스트할 때 사용해보니 괜찮은 것 같아서 정리를 해봅니다. 스프링을 넘어서 내부에서 호출되는 메소드에 인자를 잘 전달하는가 를 테스트하는 방법입니다. ( 소스코드 ) 1. 테스트 세팅 컨트롤러 레이어에서 서비스 레이어에 적절한 인자를 전달하는지 테스트하는 방식으로 진행하겠습니다. 다이어그램의 파란색 화살표에 포커스된 테스트를 작성할 것입니다. 컨트롤러 클래스 코드입니다. 아주 간단한 3개의 엔드포인트를 가지고 있습니다. ( 게시글 조회 / 게시글 생성 / 게시글 목록 조회 ) 서비스 코드는 인터페이만 노출할 뿐 내용은 없습니다. 서비스에서 사용되는 간단한 dto 입니다. 그리고 컨트롤러를 테스트하기 위한 테스트 코드도 작성해줍니다. 2. 테스트 작성 개별 게..
-
argThat을 사용해서 primitive 타입을 확인하려고 할 때 주의사항프레임워크/JUnit 2024. 4. 17. 00:24
1. argThat을 사용할 때 NullPointExeception을 만날 수 있습니다. "org.mockito.ArgumentMatchers.argThat(org.mockito.ArgumentMatcher)" is null 문제의 코드입니다. 서비스 메소드에서 Long이 아닌 long을 받고 있습니다. argThat을 사용해서 id를 비교하려고 하니 예외가 발생합니다. argThat은 기본적으로 Wrapper type을 기대하는데 primitive 타입을 사용하니 NullPointException을 던집니다. 이럴 때는 eq() 사용해서 더욱 간단히 표현하면 좋겠습니다.
-
멀티 쓰레드 환경에서 게시글 조회수 증가에 대한 검증프레임워크/JUnit 2024. 4. 15. 21:40
조회수 증가와 같이 동시에 여러 쓰레드에서 접근하는 Race condition이 발생할 수 있는 상태가 적절하게 대응이 되어있는지 확인하기 위한 테스트를 작성해보겠습니다. 모든 예제는 깃헙 소스코드의 concurrency 프로젝트에서 확인 가능합니다. 이 글은 다음과 같은 구성으로 작성되었습니다. 1. 프로젝트 세팅 2. 테스트 코드 작성 3. 멀티 쓰레드 환경의 테스트 코드는 어떻게 진행되는 것일가? 4. 동시성 이슈로부터 안전한 코드 만들기 5. 테스트 util 생성하기 1. 프로젝트 세팅 가장 기본적인 형태로 프로젝트가 구성되어 있습니다. 서비스 레이어에는 생성과 조회를 담당하는 2가지 메소드가 있습니다. Repository에서는 JPA 를 사용하고 있고, 비관적락을 사용하는 메소드를 별도로 구현하..