WAL( Write Ahead Log ) Corruption ?
* WAL Corruption?
- 디스크로 데이터를 flush 하는 도중 agent 가 죽을 때? OOM 이나 hard shutdown 같은게 일어나면 ?
* WAL? Prometheus? Time series database?
1. Time series data 란?
- 시간에 따라 저장된 데이터
- 동일한 소스로부터 시간 경과에 따라 변화를 추적하는데 용이함.
2. Time Series Database?
- 시계열 데이터 처리 위해서 빠르고 정확하게 실시간으로 쌓이는 대규모 데이터 처리할 수 있도록 고안.
- Time-stamp 를 기반으로 하는 저장소를 가지고 있다, 이를 압축 요약 하는 등의 작업을 진행하여 대규모의 시간 기반 데이터 다루고 시간을 기반으로 쿼리를 가능하게 한다.
identifier -> (t0, v0), (t1, v1), (t2, v2), (t3, v3), ....
// t 는 시간 v 는 value
3. Small Overview of TSDB
- 먼저 데이터 ( time series ) 가 들어오면 우선 WAL 으로 가서 데이터를 씀과 동시에 Head 에서도 해당 데이터를 저장 한다. 이 과정에서 memory 에 작성 되고 있는 데이터는 M-map 에 차곡차곡 저장 되게 되고 일정 시간이 지나면 해당 데이터들은 영구적인 데이터가 되어서 storage 에 저장 되게 된다.
M-map -> disk
WAL -> disk
Head -> memory
* Solution?
1. Just delete the WAL on the disk and restart the Agent
https://github.com/grafana/agent/issues/1838
위 방법에서는 저렇게 제거 해서 문제를 해결 및 promethues 에 옵션을 줘서 corrupt-wal-removal 를 통해서 자동으로 지우는 것을 제안하고 있다.
https://github.com/grafana/agent/pull/1873
truncate all records in wal if repair fails by rlankfo · Pull Request #1873 · grafana/agent
PR Description In some instances, WAL repair may fail which can cause the agent to need manual intervention from users to delete the WAL. Which issue(s) this PR fixes #1838 Notes to the Reviewer ...
github.com
해당 코드에서 그렇게 진행하는거 같은데 과연 잘 될지는 안해봐서 모르겠습니다...
Reference
- https://mangkyu.tistory.com/188
[TSDB] 시계열 데이터베이스(TSDB, Time Series Database) 란? - (1/2)
최근에 관계형 데이터베이스(Relational Database)와 NoSQL(비관계형 데이터베이스)에 이어 많은 주목을 받는 시계열 데이터베이스(TSDB, Time Series Database)가 있습니다. 이번에는 TSDB에 대해 간단히 살펴
mangkyu.tistory.com
- https://ganeshvernekar.com/blog/prometheus-tsdb-the-head-block/
Prometheus TSDB (Part 1): The Head Block | Ganesh Vernekar
Walk-through on how the in-memory part of Prometheus TSDB works
ganeshvernekar.com
- https://web.archive.org/web/20210622211933/https://fabxc.org/tsdb/