Amazon Aurora PostgreSQL returns stale data | Amazon Aurora PostgreSQL에서 이전 데이터가 반환되는 케이스

0

0

I'm reaching out regarding an intermittent issue in our application where data, despite being present, is occasionally reported as missing. We are currently utilizing Amazon Aurora PostgreSQL v10.21, operating within a Python Flask environment with SQLAlchemy ORM.

Our setup involves Writer and Reader instances; the Writer handles tasks such as writing and deletion, while the Reader is dedicated to reading operations. An issue arises when, after creating specific data (identified by unique identifiers) in the Writer session, the Reader session reports the data as non-existent when attempting to retrieve it.

We start the retrieval process not immediately, but around 6 seconds after the data creation, assuming this time frame is sufficient for replication from Writer to Reader. However, the Reader continues to report the absence of this data. Upon examining the logs and conducting searches, the data is indeed present (and there was no replica lag at the time).

To address this, we implemented a defensive mechanism, performing repeated queries over approximately 24 seconds at 6-second intervals. Unfortunately, this approach hasn't been effective.

We've observed no other issues with DB Write IOPS or CPU usage. Our current suspicion lies with either a potential issue in the DB engine or a bug in the SQLAlchemy ORM we are using. We've thoroughly reviewed our application logic and believe it to be error-free. Furthermore, reprocessing with actual data suggests that if there were a logic problem, it would have manifested consistently across all data.

If anyone has experienced similar issues, I would appreciate insights on how they were resolved or suggestions on what might be the underlying cause. Notably, while the AWS Aurora Postgres patch notes mentioned a resolved issue in version 10.11, we are using version 10.21, leading us to question whether the engine might still be implicated and seeking insights from others' experiences.

Thanks.

안녕하세요.

Application에서 데이터를 조회시 간헐적으로 데이터가 있음에도 없다는 결과값을 받아 문의 드립니다.

현재 Amazon Aurora PostgreSQL v10.21을 사용하고 있으며, 이를 Python Flask 환경에서 SQLAlchemyORM을 이용해 사용하고 있습니다.

Writer / Reader Instance를 이용하여 Writer에서는 쓰기/삭제와 같은 작업을, Reader에서는 읽기와 같은 작업을 수행하고 있습니다. Writer Session에서 특정 데이터를 만들고 나서(이는 식별자로 구분되어 있음), Reader에서 데이터를 조회하려고 하는데 Reader에서 조회했을 때 데이터가 없다고 나옵니다.

물론 Writer Session에서 생성을 하고 바로 Reader에서 조회를 하는 것이 아닌, 약 6초 후에 조회를 시작합니다. (6초정도면 Writer -> Reader 복제 시간으로 충분하다고 봅니다.)

그럼에도 Reader 에서 데이터가 없다고 나오고, 해당 로그를 기반으로 데이터를 검색하였을 때 실제로는 있음을 확인하였습니다. (당시 Replica lag은 없었습니다.)

해당 부분을 방어하려고 방어 로직으로 6초를 Interval로 총 4회, 약 24초동안 조회하는 로직 또한 추가해보았으나 별 다른 효과가 없습니다.

DB Write IOPS, CPU 등에는 다른 문제사항이 발견되지 않았으며, 저희는 이를 DB Engine의 이슈거나, Application에서 사용중인 SQLAlchemyORM의 버그로 추측하고 있습니다. (Application Logic에서는 이슈가 없었습니다. 몇번이고 복기해보았고, 실제 데이터를 다시 넣고 돌렸을 때 로직에 문제가 있었다면, 모든 데이터에 대해 이슈가 발생했을 것이라고 생각됩니다.)

혹시 관련하여 비슷한 증상을 겪으신 분이 있다면, 어떤 방식으로 해결했는지. 혹은 어느 부분을 더 의심해보아야 할까요? (AWS Aurora Postgres 패치노트에 저희가 찾고있던 이슈가 10.11에서 패치되었다고 하는데, 10.21을 사용하고 있어 Engine 쪽이 정말 아닌지, 다른분들은 겪으신 바가 없는지 궁금합니다.)

감사합니다.

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인