분류 전체보기
-
2024.09.03 Double ChargesTIL 2024. 9. 3. 23:03
How To Prevent Double Charges In eCommerce PaymentsSeveral topics like this are discussed on my YouTube channel. Please visit. I appreciate your support.medium.com커머스 서비스에서 네트워크 이슈등으로 여러번 결제요청이 들어올때 중복결제가 이뤄질 수 있다는 것 입니다.글에서 제시한 해결법으로는 멱등성을 활용하는 것 입니다.클라이언트에서 uuid를 서버에 제공하면 서버는 uuid를 기반으로 멱등성을 유지합니다.글을 읽다 우려되는 것은 새로고침등으로 uuid가 바뀌면 의미없다는 생각입니다..음 새로고침은 새결제로 판단하는 것이 맞을까요
-
2024.09.02 data replicatedTIL 2024. 9. 3. 00:14
https://medium.com/@_sidharth_m_/how-is-data-replicated-in-distributed-systems-0fe7dd8af904 How is Data Replicated in Distributed Systems?Understanding Single Leader, Multi-Leader, and Leaderless Replicationmedium.com 데이터베이스 복제 관련 글을 읽었습니다. 단일 리더, 멀티 리더, 리더 없음의 방식을 소개합니다. 단일리더는 노드 하나만 업데이트문을 수신하는 것 입니다. 리더 다운 시 리더의 복구를 기다리거나 새 리더를 선출합니다. 그 간격동안은 장애시간이 됩니다. 복제 방법도 동기복제와 비동기 복제가 있습니다. 멀티 리더는 모드 노드..
-
Lock에 대해 알아보기: Gap Lock글또 2024. 9. 1. 13:55
0. 들어가며 안녕하세요. 오늘은 Gap Lock에 대해 알아보려고 합니다.Gap Lock에 관심을 갖게 된 이유는 재고 관련 Locking을 공부하다가 궁금한 점이 생겼기 때문입니다. 재고 정합성을 위해 SELECT FOR UPDATE를 사용하고 있었는데, 이에 대해 참고 자료를 살펴보던 중 SELECT FOR UPDATE를 사용할 때 발생할 수 있는 Deadlock에 관한 설명을 보았습니다.이 Deadlock은 단순한 자원 경합에 의한 것이 아니라, MySQL의 고유한 Lock 특성으로 인해 발생하는 것이었습니다. 그래서 이 문제의 원인인 Gap Lock에 대해 더 깊이 알아보고 공부해 보려고 합니다. Gap Lock 이란 무엇인가?Gap Lock 의 필요이유는 무엇인가?PK, UK예제당근 글 분석 ..
-
Lock에 대해 알아보기: Gap Lock 2글또 2024. 8. 30. 00:37
0. 들어가며이전 글에서 Gap Lock에 대해 알아보았습니다.단순 INSERT 문은 Gap Lock을 걸지 않는다는 것을 알게 되었습니다.다만, INSERT 문은 Gap에 대해 Insert Intention Lock을 건다는 사실도 확인했습니다.Insert Intention Lock은 Gap Lock과 유사하지만, 범위가 겹치지 않는다면 INSERT가 가능한 Lock입니다. 공식 문서를 살펴보던 중, INSERT로 인해 Deadlock이 발생하는 예제를 발견했습니다. INSERT가 Gap Lock을 사용하지 않는다고 알고 있었는데, 어떤 이유로 문제가 발생했는지 궁금해졌습니다. 오늘은 공식 문서의 예시를 통해 이 문제를 이해해보도록 하겠습니다 💡 LOCK_MODE 데이터 확인S, X : 넥스트 키..
-
2024.08.28 system design interviewsTIL 2024. 8. 28. 23:50
I conducted system design interviews at Meta. Here’s how to prep.When coordinating your interview at Meta (formerly Facebook), you’ll be asked whether you want to do a System Design Interview (“Pirate”)…grokkingtechinterview.com시스템 디자인 면접에서는 커뮤니케이션이 중요합니다. 커뮤니케이션을 통해 명확한 요구사항을 파악해야 하고 특정 컴포넌트에 대해서 깊이 있는 지식을 가지고 있다고 어필해야 합니다.디자인 후 질문 시간을 충분히 남겨둬야 깊은 커뮤니케이션을 할 수 있다고 한다. 질문과 예제를 보면 요구사항을 정리하고 기능적 ..
-
2024.08.23 Deadlock on rollback, but not on commit, when using ON DUPLICATE KEYTIL 2024. 8. 23. 22:37
MySQL :: MySQL 8.4 Reference Manual :: 17.7.3 Locks Set by Different SQL Statements in InnoDB17.7.3 Locks Set by Different SQL Statements in InnoDB A locking read, an UPDATE, or a DELETE generally set record locks on every index record that is scanned in the processing of an SQL statement. It does not matter whether there are WHERE conditions indev.mysql.com오늘은 insert on duplicate key update를 봤습..
-
재고 정합성이 걱정되어서 써보는 글(MVCC)글또 2024. 8. 21. 23:36
0. 들어가며안녕하세요.이번에는 회사에서 개발하고 있는 재고 시스템에서 고민했던 점을 써보려고 합니다.내용적으로는 MVCC와 lock에 대한 이야기입니다. 전체적인 개념이 아닌 제가 궁금했던 점만 기술하니 참고 바랍니다.이 글은 MySql 5.6의 기본설정인 innodb와 repeatable read를 전제로 합니다. 갑자기 궁금해졌다MVCC의 목적Update Where... / Delete Where... (Consistent Nonlocking Reads)우리의 재고 정합성을 위해 무엇을 해야 하는가 1. 갑자기 궁금해졌다.새로 개발하고 있는 재고 관리 시스템에서 여러 명이 동시에 재고를 이동시키면 문제가 없을까? 문제가 없는 경우는 유저가 한 명이고 순차적으로 기능을 실행시켜야만 가능한 이야기입니..
-
2024.08.20 foreign keyTIL 2024. 8. 20. 23:35
foreign key 에 의한 부모, 자식 테이블의 잠금관계http://blog.naver.com/parkjy76/220588832494 에서도 잠깐 언급을 했는데 foreign key 제약을 사용할 경우...blog.naver.com오늘도 외래키에 대해서 봤습니다..외래키로 인해서 dead lock이 나는 경우가 있습니다.쿼리에 사용된 외래키에 s lock을 걸기 때문입니다.서로다른 트랜잭션이 서로 부모,자식 테이블에 잠금을 획득하려할 때 발생할 수 있습니다.잠금 해결법에는 트랜잭션 시작시 사용될 잠금을 모두 획득한 후 쿼리를 진행하는 방법이 있을 거 같습니다.