Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

사용자가 Supabase 의 스토리지 API 에 파일업로드를 성공하였으나, 데이터베이스에서 관련된 데이터 insert 를 실패하였을때, Storage 롤백 처리를 위한 로직 작성 #18

Open
jukangpark opened this issue Aug 24, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jukangpark
Copy link
Owner

Is your feature request related to a problem? Please describe.
현재 파일 업로드 관련된 Supabase 의 스토리지 API 가 만약 실패했을 때에는, DB 에 데이터를 insert 하지 않지만,
만약 Supabase 의 스토리지 API 가 성공하였지만, DB 에 데이터를 insert 하는게 실패했을때에는 스토리지에 데이터가 남아있게됨

Describe the solution you'd like
파일 업로드와 관련된 작업은 Supabase의 스토리지 API를 사용하는 것으로, 이는 데이터베이스 트랜잭션과는 별도로 처리됩니다.
따라서 파일 업로드와 데이터베이스 삽입을 모두 하나의 트랜잭션으로 묶는 것은 일반적으로 불가능합니다.
하지만, 데이터베이스 작업 자체는 트랜잭션으로 묶을 수 있습니다.

다음과 같은 방법으로 코드를 수정할 수 있습니다:

  1. 파일 업로드가 성공한 후에 데이터베이스 작업을 트랜잭션으로 묶습니다.
  2. 데이터베이스 트랜잭션이 실패하면 업로드된 파일을 삭제하는 방식으로 일관성을 유지할 수 있습니다.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
https://supabase.com/docs/guides/storage

@jukangpark jukangpark added the bug Something isn't working label Aug 24, 2024
@jukangpark jukangpark self-assigned this Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant