AWS

아무 업데이트가 없던 주말 동안, 아시아 지역 CloudFront 불완전한 다운로드 비율이 절반 수준으로 개선(2023-08-25)

요청 건수 차이 없음(위), 불완전한 다운로드 개선(아래)
<요청 건수 차이 없음(위), 불완전한 다운로드 개선(아래)>[원본 보기]
상위 국가 요청 비율에 큰 차이 없음
<상위 국가 요청 비율에 큰 차이 없음>[원본 보기]

EC2 스팟 인스턴스 - 최소 비용 전략 사용 시, 인스턴스가 빈번히 교체되는 모습(2023-01-12)

20230112_145950.png
<20230112_145950.png>[원본 보기]

CPU 사용률이 100을 초과하는 현상(2022-01-21)

EC2 및 ElastiCache(Redis)에서 발생

EC2 스크린샷
<EC2 스크린샷>[원본 보기]
Redis 스크린샷
<Redis 스크린샷>[원본 보기]

WAF 규칙 적용 후 평균 응답 시간(P95, P99 포함 전부)이 획기적으로 단축된 것으로 보고되는 현상(2022-01-16)

ALB 통계에 포함되는 처리 시간 일부가 WAF 규칙 평가로 옮겨가서?

photo_2022-02-10 16.21.20.jpeg
<photo_2022-02-10 16.21.20.jpeg>[원본 보기]

C#

SSL 인증 오류

  • 아래는 테스트 환경에서나 쓸 법한 코드로, 인증서를 무조건 신뢰한다
  • ↓ cs

    //Trust all certificates System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true); // trust sender System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, cert, chain, errors) => true); // validate cert by calling a function ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback((sender, cert, chain, policyErrors) => true);
  • .NET 권장사항

Docker

컨테이너 에러 종료 후 재시작 불가

  1. Error response from daemon: container "83a7208d6b68d3d97be501b47d6a4bb28245b086f25eda819dec93a8d40320a3": already exists
  2. 아래 명령으로 컨테이너의 잔존 메타데이터를 지우면 다시 시작할 수 있다
  3. ↓ shell

    docker-containerd-ctr --namespace moby --address /var/run/docker/containerd/docker-containerd.sock c rm [container_id]

    container_id는 전체를 넘겨줘야 하고, address 옵션값은 정확한 경로로 넘겨줘야 한다

Eclipse

자동완성 불가; No Java Proposals

  1. Windows - Preferences - Java - Editor - Content Assist - Advanced
    • ↑ 설정 검색창에 proposal 입력하면 빠르게 항목을 찾을 수 있다
    • 해당 설정에서 자동 완성 제안에 표시되지 않은 항목이 있다면 체크하고 적용한다
  2. 위 설정에 문제가 없는 경우
  3. {WORKSPACE_DIRECTORY}/.metadata/.plugins/org.eclipse.jdt.core 디렉터리에서 *.index, savedIndexNames.txt를 지우고 재실행

  4. 참고

애너테이션 처리 오류

  1. 예외 : DOMA4011, javax.annotation.processing.FilterException: Source file already created
  2. 원인 : 이클립스 배치 모드에서 특정 파일 수(2000)를 초과하면 애너테이션 처리에 버그 발생
  3. 해결 : eclipse.ini vmargs 섹션에 아래처럼 추가
  4. ↓ ini

    -vmargs -DmaxCompiledUnitsAtOnce=20000
  5. 참고 1참고 2

Export > Runnable JAR File > Launch Configuration 비어있음

  1. Run as > Java Application 1회 실행하면 목록에 표시됨
  2. 참고

Git

SSH 관련

/Users/xxx/.ssh/config

↓ text

Host Donggi-GitHub HostName github.com User "Donggi Kim" IdentityFile /Users/xxx/.ssh/id_rsa IdentitiesOnly yes

Windows 소스트리 > PuTTY 최초 인증시 수동 확인

↓ shell

C:\Users\xxx\AppData\Local\SourceTree\app-3.4.10\tools\putty\plink.exe github.com

login as : git

Heroku

콘솔 출력 스트림 깨지는 현상 (2023-11-15 및 과거에도 몇 차례)

콘솔 출력이 불가능했기 때문에 Heroku 로그에는 기록조차 되지 않았고, uncaughtException 핸들러를 이용해 Slack으로 스택을 전송함

↓ Node 에러 스택

Error: write EPIPE at afterWriteDispatched (node:internal/stream_base_commons:160:15) at writeGeneric (node:internal/stream_base_commons:151:3) at Socket._writeGeneric (node:net:905:11) at Socket._write (node:net:917:8) at writeOrBuffer (node:internal/streams/writable:391:12) at _write (node:internal/streams/writable:332:10) at Socket.Writable.write (node:internal/streams/writable:336:10) at console.value (node:internal/console/constructor:299:16) at console.log (node:internal/console/constructor:376:26)

빈번한 재시작 (2022-11-04)

기본 재시작 주기는 1일이지만, 고작 10분 만에 SIGTERM 신호를 보내는 경우도 존재

↓ shell

$ heroku logs --app=xxx 2022-11-04T15:42:53.188721+00:00 heroku[web.1]: Cycling 2022-11-04T15:42:53.191834+00:00 heroku[web.1]: State changed from up to starting 2022-11-04T15:42:54.745019+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-11-04T15:42:54.935443+00:00 heroku[web.1]: Process exited with status 143 2022-11-04T15:43:04.647817+00:00 heroku[web.1]: Starting process with command `node app` 2022-11-04T15:43:07.865400+00:00 app[web.1]: Express server listening on 26655 2022-11-04T15:43:08.358056+00:00 heroku[web.1]: State changed from starting to up 2022-11-05T15:59:52.193485+00:00 heroku[web.1]: Cycling 2022-11-05T15:59:52.199264+00:00 heroku[web.1]: State changed from up to starting 2022-11-05T15:59:52.827689+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-11-05T15:59:53.127857+00:00 heroku[web.1]: Process exited with status 143 2022-11-05T16:00:03.219442+00:00 heroku[web.1]: Starting process with command `node app` 2022-11-05T16:00:05.914223+00:00 app[web.1]: Express server listening on 27518 2022-11-05T16:00:06.014664+00:00 heroku[web.1]: State changed from starting to up 2022-11-06T16:28:34.682573+00:00 heroku[web.1]: Cycling 2022-11-06T16:28:34.684590+00:00 heroku[web.1]: State changed from up to starting 2022-11-06T16:28:35.298049+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-11-06T16:28:35.536632+00:00 heroku[web.1]: Process exited with status 143 2022-11-06T16:28:46.543968+00:00 heroku[web.1]: Starting process with command `node app` 2022-11-06T16:28:49.632588+00:00 app[web.1]: Express server listening on 46591 2022-11-06T16:28:50.176669+00:00 heroku[web.1]: State changed from starting to up 2022-11-07T17:03:23.014423+00:00 heroku[web.1]: Cycling 2022-11-07T17:03:23.018550+00:00 heroku[web.1]: State changed from up to starting 2022-11-07T17:03:23.773273+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-11-07T17:03:23.997377+00:00 heroku[web.1]: Process exited with status 143 2022-11-07T17:03:35.633367+00:00 heroku[web.1]: Starting process with command `node app` 2022-11-07T17:03:38.101356+00:00 app[web.1]: Express server listening on 12207 2022-11-07T17:03:38.542343+00:00 heroku[web.1]: State changed from starting to up 2022-11-08T17:44:34.257748+00:00 heroku[web.1]: Cycling 2022-11-08T17:44:34.260294+00:00 heroku[web.1]: State changed from up to starting 2022-11-08T17:44:34.961998+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-11-08T17:44:35.349123+00:00 heroku[web.1]: Process exited with status 143 2022-11-08T17:44:44.719748+00:00 heroku[web.1]: Starting process with command `node app` 2022-11-08T17:44:47.333908+00:00 app[web.1]: Express server listening on 14749 2022-11-08T17:44:47.536761+00:00 heroku[web.1]: State changed from starting to up 2022-11-09T18:05:53.566487+00:00 heroku[web.1]: Cycling 2022-11-09T18:05:53.569847+00:00 heroku[web.1]: State changed from up to starting 2022-11-09T18:05:54.158427+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-11-09T18:05:54.634928+00:00 heroku[web.1]: Process exited with status 143 2022-11-09T18:06:03.068936+00:00 heroku[web.1]: Starting process with command `node app` 2022-11-09T18:06:05.511106+00:00 app[web.1]: Express server listening on 28627 2022-11-09T18:06:05.944568+00:00 heroku[web.1]: State changed from starting to up 2022-11-09T20:45:53.115643+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-11-09T20:45:53.542677+00:00 heroku[web.1]: Process exited with status 143 2022-11-09T20:46:57.112428+00:00 heroku[web.1]: State changed from up to down 2022-11-09T20:46:57.114989+00:00 heroku[web.1]: State changed from down to starting 2022-11-09T20:47:08.875162+00:00 heroku[web.1]: Starting process with command `node app` 2022-11-09T20:47:13.184638+00:00 app[web.1]: Express server listening on 52035 2022-11-09T20:48:42.474102+00:00 heroku[web.1]: State changed from starting to up 2022-11-09T20:56:48.120912+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-11-09T20:56:50.546725+00:00 heroku[web.1]: Process exited with status 143 2022-11-09T20:57:19.805546+00:00 heroku[web.1]: State changed from up to down 2022-11-09T20:57:19.807460+00:00 heroku[web.1]: State changed from down to starting 2022-11-09T20:57:34.022542+00:00 heroku[web.1]: Starting process with command `node app` 2022-11-09T20:57:41.713346+00:00 app[web.1]: Express server listening on 25985 2022-11-09T20:57:45.249367+00:00 heroku[web.1]: State changed from starting to up

Java

Cannot access class jdk.internal.misc.Unsafe

  1. 실행 옵션 추가하여 모듈 개방
  2. ↓ shell

    --add-opens java.base/jdk.internal.misc=ALL-UNNAMED
  3. 참고

java.io.EOFException: Unexpected end of ZLIB input stream

  • at java.base/java.util.zip.GZIPInputStream.read
  • ch.qos.logback.core.rolling.helper.CompressionMode.GZ 사용 시 간헐적으로 압축 누락 발생

java.lang.NoClassDefFoundError

컨테이너로 jar 실행 중인 상태에서 jar 파일을 교체했지만 컨테이너 재시작은 하지 않은 경우 발생 가능?

java.text.ParseException: Unparseable date: "2028-07-25 15:00:00"

  1. 아스키 공백 문자(32)가 맞는지 확인한다
  2. 20200227_143848.png
    <20200227_143848.png>[원본 보기]
    20200227_145006.png
    <20200227_145006.png>[원본 보기]

MySQL

시간 기본값 0 설정이 안 될 때

  1. 왜 굳이 now(), NULL, 특정 시각 상수가 아닌 0을 이용하려는지는 모르겠지만...
  2. 원인 : 서버에 NO_ZERO_DATE 옵션이 설정됐기 때문
  3. 옵션 확인
  4. ↓ sql

    SHOW VARIABLES LIKE 'sql_mode' -- 또는 SELECT @@sql_mode
  5. 해결 1
  6. ↓ sql

    SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'NO_ZERO_DATE',''));
  7. 해결 2 : /etc/my.cnf 수정
  8. ↓ ini

    [mysqld] sql_mode="수정값"

Nginx

open() ... failed (13: Permission denied)

  • location에서 설정한 디렉터리가 실제로 존재하는지?
  • nginx.conf에서 설정한 user로 디렉터리를 조회할 수 있는지? == x 권한 설정
  • [SELinux] 디렉터리가 http 컨텐츠인지?
  • ↓ shell

    $ chcon -Rt httpd_sys_content_t /path/to/www
  • 참고 1참고 2참고 3

Node

Cannot find module or its corresponding type declarations

  1. tsconfig.json의 moduleResolution 설정이 제대로 되었는지 확인
  2. 미설정한 경우, deprecated된 값(classic)이 이용된다

  3. tsconfig.json의 forceConsistentCasingInFileNames 설정을 켰는지 확인
  4. node_modules 디렉터리를 삭제하고 재설치 시도
  5. 참고 자료

PostgreSQL

AWS Redshift와 드라이버 충돌

Connection url에OpenSourceSubProtocolOverride=true 추가

remaining connection slots are reserved for non-replication superuser connections

  1. 원인 : 일반적으로 최대 연결 수 부족
  2. 해결1 : /var/lib/pgsql/data/postgresql.conf
  3. ↓ ini

    max_connections=${적당히_큰_숫자}
  4. 해결2 : 연결 강제로 끊기
  5. ↓ sql

    select distinct pg_terminate_backend(pid) from pg_stat_activity where client_addr = 'x.x.x.x';
  6. 참고

로그 유실?

파이프 제한으로 쓰기가 무시(그리고 유실)될 수 있다

  • 참고 자료 : stream.html#writablewritechunk-encoding-callback, 2024-10-09-node-stdout-disappearing-bytes
  • 스트림 쓰기는 OS와 스트림이 어디에 연결됐는가에 따라 동기적일수도, 비동기적일수도 있다
    WindowsPOSIX
    Filesyncsync
    TTYasyncsync
    Pipe and Socketsyncasync
  • Node의 writable.write()는 'drain' 이벤트를 대기하는 동안에는 false를 반환하고 쓰기를 수행하지 않는다
  • 이로 인해 스트림을 파일에 쓸 때와, 다른 프로세스로 파이프할 때 결과가 다를 수 있다

    ↓ shell

    $ node -e "console.log('@'.repeat(128 * 1024)); process.exit(0);" | wc -c 65536 $ node -e "console.log('@'.repeat(128 * 1024)); process.exit(0);" > node-stdout-test.out && wc -c node-stdout-test.out 131073 node-stdout-test.out

logrotate 롤링 시점의 로그가 유실될 수 있다

  • 참고 자료 : logrotate, 27
  • copytruncate 옵션은 편리하지만, copy 후 truncate 하는 사이에 기록된 로그는 유실될 수 있다 -- copy가 오래 걸릴수록 유실되는 크기도 커진다

    Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost

  • 따라서 copytruncate 옵션이 적합하지 않은 경우, 프로세스에 시그널을 보내 새로운 파일(이름이 이전과 동일하든 그렇지 않든)에 로그를 기록하도록 지시하는 것이 좋다

    ↓ Nginx 예.

    postrotate if [ -f /.../nginx.pid ]; then kill -USR1 $(cat /.../nginx.pid) fi endscript

서버 응답이 잘려서 올 때

  1. Linux > docker-machine > container(서버) 환경에서, Linux 서버의 용량이 부족할 때 이하의 현상이 발생함을 확인
    • container, docker-machine에서 서버 응답은 정상 획득
    • Linux 서버 및 그 밖에서는 서버 응답이 잘림

암호화 오류. Padding is invalid and cannot be removed

  1. 스트림을 직접 이용하는 경우, flush 완료됐는지 확인이 필요하다
  2. ↓ C# 암호화

    var source = File.ReadAllBytes("source_file"); using var aes = Aes.Create(); aes.Key = Encoding.ASCII.GetBytes("32 Bytes String"); aes.IV = Encoding.ASCII.GetBytes("16 Bytes String"); using var mStream = new MemoryStream(); { using var cStream = new CryptoStream(mStream, aes.CreateEncryptor(), CryptoStreamMode.Write); cStream.Write(source, 0, source.Length); } // 블록을 추가하여 암호화 스트림이 먼저 flush + close하도록 보장 var target = mStream.ToArray();

    ↓ C# 복호화

    { var source = File.ReadAllBytes("source_file"); var aes = Aes.Create(); aes.Key = Encoding.ASCII.GetBytes("32 Bytes String"); aes.IV = Encoding.ASCII.GetBytes("16 Bytes String"); using var mStream = new MemoryStream(source); using var cStream = new CryptoStream(mStream, aes.CreateDecryptor(), CryptoStreamMode.Read); using var fStream = new FileStream("target_file", FileMode.Create); var buf = new byte[source.Length]; var length = cStream.Read(buf, 0, buf.Length); fStream.Write(buf, 0, length); } // 블록을 추가하여 모든 스트림이 알아서 닫히도록 구성
  3. 참고

Linux WebSocket 서버의 연결이 일정 개수 이상 수립되지 않음

↓ /etc/security/limits.conf 수정 예

# soft <= hard * soft nofile 500000 * hard nofile 500000 <user_name> soft nofile 500000 <user_name> hard nofile 500000
  • 리눅스에서는 소켓 연결도 파일이다(프로세스가 아닌 건 대부분 파일이다)
  • RHEL 7 기준, limis.conf 적용 후 /etc/security/limits.d/20-nproc.conf의 설정으로 값이 변경될 수 있으니, 같이 수정 필요하다고 함
  • 별개로 전체 시스템의 파일 수 제한도 확인
  • ↓ shell

    $ sysctl fs.file-max
  • 시스템 backlog 조정 // 웹서버에서 별도로 설정이 필요할 수 있음
  • ↓ shell

    $ sysctl -w net.core.netdev_max_backlog="2048"
  • increasing-the-number-of-outbound-tcp-connections

수신한 패킷이 버려짐