Development
-
사내 서비스에 소나큐브로 정적분석을 도입한 후, 무수히 많은 Bugs와 Code Smells가 발견되었다 😑대체 어떤 버그가 이렇게 많은 것일까.. 궁금했던 나는 Overall Code 기준으로 심각도가 높은 Bugs를 모두 파헤쳤고, 빈번하게 발생한 Bugs를 정리해보았다.최소한 기본적인 버그는 만들지 않는 개발자가 되자! 🤔 🚦 Levels: Blocker⛔️ Create class "Exception" in namespace or check correct import of class🔖 IssueClass of caught exception should be defined사용하는 클래스는 꼭 import를 해주자✅ How to fix// AS-IS// ..생략} catch (Exception ..
소나큐브 PHP 코드 분석: 주요 Bugs 및 해결 방안 정리사내 서비스에 소나큐브로 정적분석을 도입한 후, 무수히 많은 Bugs와 Code Smells가 발견되었다 😑대체 어떤 버그가 이렇게 많은 것일까.. 궁금했던 나는 Overall Code 기준으로 심각도가 높은 Bugs를 모두 파헤쳤고, 빈번하게 발생한 Bugs를 정리해보았다.최소한 기본적인 버그는 만들지 않는 개발자가 되자! 🤔 🚦 Levels: Blocker⛔️ Create class "Exception" in namespace or check correct import of class🔖 IssueClass of caught exception should be defined사용하는 클래스는 꼭 import를 해주자✅ How to fix// AS-IS// ..생략} catch (Exception ..
2024.08.18 -
📌 이슈현재 회사에서 php 7.0와 8.2, 2개 버전의 서비스를 관리하고 있다.8.2로 버전업하면서 7.0에서 숨어있던 여러 레거시로 인한 에러들이 나타나기 시작했다.UPDATE {table}SET {column}={value}WHERE {column} IN ();최근에는 syntax 에러를 유발하는 동일한 쿼리임에도 버전별로 결과가 7.0에서는 에러가 무시되고 있던 것을 발견했다.📝 분석https://www.php.net/manual/en/mysqli-stmt.execute.php7.0에서는 이슈 쿼리를 execute()할 경우, UPDATE 처리할 대상이 없기에 아무런 동작도 발생하지 않고 함수가 종료되는 것을 확인했다.You have an error in your SQL syntax; che..
PHP 8.1: MYSQLI_REPORT 기본 오류 모드 변경📌 이슈현재 회사에서 php 7.0와 8.2, 2개 버전의 서비스를 관리하고 있다.8.2로 버전업하면서 7.0에서 숨어있던 여러 레거시로 인한 에러들이 나타나기 시작했다.UPDATE {table}SET {column}={value}WHERE {column} IN ();최근에는 syntax 에러를 유발하는 동일한 쿼리임에도 버전별로 결과가 7.0에서는 에러가 무시되고 있던 것을 발견했다.📝 분석https://www.php.net/manual/en/mysqli-stmt.execute.php7.0에서는 이슈 쿼리를 execute()할 경우, UPDATE 처리할 대상이 없기에 아무런 동작도 발생하지 않고 함수가 종료되는 것을 확인했다.You have an error in your SQL syntax; che..
2024.08.05 -
📌 TipsIf a method can be static, declare it static. Speed improvement is by a factor of 4. ➜ static 메서드는 일반 메서드보다 4배 빠르다echo is faster than print. ➜ echo가 print보다 빠르다Set the maxvalue for your for-loops before and not in the loop. ➜ for 루프을 위핸 최대값(탈출조건)을 루프 안에서가 아니고 루프 시작 이전에 지정하라.Unset your variables to free memory, especially large arrays. ➜ 메모리를 해제하기 위해 변수를 unset하라. 특히 커다란 배열은 그래야 된다.Avoi..
PHP 코드 최적화 관련 팁 모음📌 TipsIf a method can be static, declare it static. Speed improvement is by a factor of 4. ➜ static 메서드는 일반 메서드보다 4배 빠르다echo is faster than print. ➜ echo가 print보다 빠르다Set the maxvalue for your for-loops before and not in the loop. ➜ for 루프을 위핸 최대값(탈출조건)을 루프 안에서가 아니고 루프 시작 이전에 지정하라.Unset your variables to free memory, especially large arrays. ➜ 메모리를 해제하기 위해 변수를 unset하라. 특히 커다란 배열은 그래야 된다.Avoi..
2024.08.03 -
📍 배경Springboot + Kotlin + H2 조합으로 간단한 API 를 구축해보려고 했다. 📍 이슈Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.2024-04-11T23:22:48.130+09:00 ERROR 38085 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************APPLICATION FAILED TO START***************************Description:Parameter 0 of..
[Error] Parameter 0 of constructor in service required a bean of type repository that could not be found.📍 배경Springboot + Kotlin + H2 조합으로 간단한 API 를 구축해보려고 했다. 📍 이슈Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.2024-04-11T23:22:48.130+09:00 ERROR 38085 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************APPLICATION FAILED TO START***************************Description:Parameter 0 of..
2024.04.11 -
⏰ 읽는 시간: 15분 들어가기 전유지보수를 하는 개발자에게 로그는 생명이다🧐 라이브 서비스와 관련된 오류 및 결함이 접수되면,가장 먼저 로그를 확인하고 로그를 토대로 이슈 구간을 확인하여 버그 원인을 추적해야 하기 때문이다 로그에 필요한 내용을 잘 기록하는 만큼 문제 해결 시간을 단축할 수 있지만반대로 로그가 부족하다면.. 그만큼 에러 원인을 찾기까지의 시간이 소요되어 서비스에 대한 고객의 만족도가 떨어지게 된다. 로그의 종류는 여러가지지만!아파치 로그, 커스텀 웹로그, 쿼리로그 등등.. 오늘은 Query Log에 대한 이야기를 하고자 한다 :)특히, 유지보수의 전쟁터인.. 현업에서의 경험을 바탕으로 쿼리 로그가 필요한 시점, 로그에 담아야할 내용 등을 정리해보려고 한다. DB Log / Query ..
[LOG] 현업에서 느낀 Query LOG 에 들어가야 할 내용⏰ 읽는 시간: 15분 들어가기 전유지보수를 하는 개발자에게 로그는 생명이다🧐 라이브 서비스와 관련된 오류 및 결함이 접수되면,가장 먼저 로그를 확인하고 로그를 토대로 이슈 구간을 확인하여 버그 원인을 추적해야 하기 때문이다 로그에 필요한 내용을 잘 기록하는 만큼 문제 해결 시간을 단축할 수 있지만반대로 로그가 부족하다면.. 그만큼 에러 원인을 찾기까지의 시간이 소요되어 서비스에 대한 고객의 만족도가 떨어지게 된다. 로그의 종류는 여러가지지만!아파치 로그, 커스텀 웹로그, 쿼리로그 등등.. 오늘은 Query Log에 대한 이야기를 하고자 한다 :)특히, 유지보수의 전쟁터인.. 현업에서의 경험을 바탕으로 쿼리 로그가 필요한 시점, 로그에 담아야할 내용 등을 정리해보려고 한다. DB Log / Query ..
2024.02.22 -
🐳 들어가기 전🔗 [Cache] PHP 에서 Memcached(멤캐시) 사용하기지난주에는 PHP로 구성된 솔루션에서 Memcached를 사용했다 한 서버에만 카나리 배포를 해서 사용량을 모니터링 해봤는데,캐시 stats 조회 시마다 고객 서버에 접근하여 telnet으로 멤캐시에 접속해 stats를 조회하는게 여간.. 귀찮은 일이 아니었다. 더불어 현재 우리 팀에서는 Secondary DB 쿼리 로그를 분석해,호출 빈도 수가 높은 쿼리들을 대상으로 Memcached로 빼려고 하는 작업을 진행 중인데cache hits율이 얼마나 높아졌는지 등의 모니터링도 쉽지 않을 것 같았다. 여러 서버의 Memcached Hits를 한눈에 볼 수 있는 방법을 고민하다가 이것저것 찾아보게 되었다.팀장님께서 고민해본다고는..
[Cache] GUI 환경에서의 Memcached 지표 수집 (Prometheus, Grafana)🐳 들어가기 전🔗 [Cache] PHP 에서 Memcached(멤캐시) 사용하기지난주에는 PHP로 구성된 솔루션에서 Memcached를 사용했다 한 서버에만 카나리 배포를 해서 사용량을 모니터링 해봤는데,캐시 stats 조회 시마다 고객 서버에 접근하여 telnet으로 멤캐시에 접속해 stats를 조회하는게 여간.. 귀찮은 일이 아니었다. 더불어 현재 우리 팀에서는 Secondary DB 쿼리 로그를 분석해,호출 빈도 수가 높은 쿼리들을 대상으로 Memcached로 빼려고 하는 작업을 진행 중인데cache hits율이 얼마나 높아졌는지 등의 모니터링도 쉽지 않을 것 같았다. 여러 서버의 Memcached Hits를 한눈에 볼 수 있는 방법을 고민하다가 이것저것 찾아보게 되었다.팀장님께서 고민해본다고는..
2024.01.21 -
🐳 들어가기 전작년부터 우선 순위를 가장 높여 처리하고 있는 업무가 하나 있다.바로 DB 접속 정보 보관 장소를 옮기는 것! 기존에는 웹서버 내 database.yml 내에 DB 접속 정보가 평문으로 노출되어 있었다.이는 해킹 등의 보안 이슈를 야기할 수 있는 원인이 되었기 때문에작년부터 모든 상점의 DB 접속 정보를 Vault로 옮기는 작업을 하고 있다. 솔루션에서는 Vault에 직접 접근하여 DB 접속 정보를 가져오지는 않고,중개 API에서 상점별 DB 접속 정보를 읽어와 로컬 캐시, Memcached에 저장하여 사용하는 방식을 택했다. 현재까지 솔루션에서 Memcached를 쓰고 있지 않았기에 새로 도입했어야 했다. 그 과정에서 Memcached 와 관련하여 겪었던 내용들을 정리해보고자 한다 !✅..
[Cache] PHP 에서 Memcached(멤캐시) 사용하기🐳 들어가기 전작년부터 우선 순위를 가장 높여 처리하고 있는 업무가 하나 있다.바로 DB 접속 정보 보관 장소를 옮기는 것! 기존에는 웹서버 내 database.yml 내에 DB 접속 정보가 평문으로 노출되어 있었다.이는 해킹 등의 보안 이슈를 야기할 수 있는 원인이 되었기 때문에작년부터 모든 상점의 DB 접속 정보를 Vault로 옮기는 작업을 하고 있다. 솔루션에서는 Vault에 직접 접근하여 DB 접속 정보를 가져오지는 않고,중개 API에서 상점별 DB 접속 정보를 읽어와 로컬 캐시, Memcached에 저장하여 사용하는 방식을 택했다. 현재까지 솔루션에서 Memcached를 쓰고 있지 않았기에 새로 도입했어야 했다. 그 과정에서 Memcached 와 관련하여 겪었던 내용들을 정리해보고자 한다 !✅..
2024.01.14 -
🐳 들어가기 전2023년 8월 초, 타 쇼핑몰 업체가 우리 업체의 솔루션으로 이전해왔다.작업 규모가 컸기 때문에 데이터 이전을 위한 임시 TF 팀이 신설되었고, 이런저런 이유로 나는 중간에 합류하게 되었다.마이그레이션 작업을 위한 로직은 파이썬으로 개발 중이었고 덩달아 나도 실무에서 처음 파이썬을 써보게 되었다.메신저가 온 걸 모르고 있었는데, 무심코 고개를 돌리니까 TF팀 팀장님이 옆에 서계셨다 (?ㅋㅋㅋ)"파이썬 처음인거 알고 있는데, 어려우면 GPT가 해줄거에요~" 라는 말에 빵터지면서 🤣 본격적으로 업무를 시작했다 ✅ 게시판나는 게시판 이전을 담당했다.우리 파트에서 내가 주로 담당한 도메인은 상품이었는데, 게시판이라 조금 낯설었지만게시판 관련 이슈를 몇번 처리한 적은 있어서 크게 부담되지는 ..
게시판 데이터 마이그레이션 with Python🐳 들어가기 전2023년 8월 초, 타 쇼핑몰 업체가 우리 업체의 솔루션으로 이전해왔다.작업 규모가 컸기 때문에 데이터 이전을 위한 임시 TF 팀이 신설되었고, 이런저런 이유로 나는 중간에 합류하게 되었다.마이그레이션 작업을 위한 로직은 파이썬으로 개발 중이었고 덩달아 나도 실무에서 처음 파이썬을 써보게 되었다.메신저가 온 걸 모르고 있었는데, 무심코 고개를 돌리니까 TF팀 팀장님이 옆에 서계셨다 (?ㅋㅋㅋ)"파이썬 처음인거 알고 있는데, 어려우면 GPT가 해줄거에요~" 라는 말에 빵터지면서 🤣 본격적으로 업무를 시작했다 ✅ 게시판나는 게시판 이전을 담당했다.우리 파트에서 내가 주로 담당한 도메인은 상품이었는데, 게시판이라 조금 낯설었지만게시판 관련 이슈를 몇번 처리한 적은 있어서 크게 부담되지는 ..
2023.08.15