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

fix(dao): ensure find and create functions thread safe #845

Merged
merged 2 commits into from
Apr 30, 2024
Merged

Conversation

qwqcode
Copy link
Member

@qwqcode qwqcode commented Apr 28, 2024

Due to the fact that find and create operations are not atomic, potential concurrency issues may arise, leading to multiple executions of the create operation (while the expectation is to execute create only once). This results in the possibility of multiple pages or similar entries in the data table. This PR addresses concurrency issues by utilizing mutex locks at the underlying level via singleflight.

We provide a tool for merging (due to this issue) duplicate pages. To run this tool when Artalk starts, add the environment variable ATK_DB_MIGRATOR_FUNC_MERGE_PAGES=1. Before executing this tool, be sure to backup the original data.

Copy link

codecov bot commented Apr 28, 2024

Codecov Report

Attention: Patch coverage is 25.96154% with 77 lines in your changes are missing coverage. Please review.

Project coverage is 27.62%. Comparing base (fbd1cd9) to head (c8d2df3).

❗ Current head c8d2df3 differs from pull request most recent head f18070e. Consider uploading reports for the commit f18070e to get more accurate results

Files Patch % Lines
internal/dao/migrate.go 4.44% 42 Missing and 1 partial ⚠️
internal/utils/cli.go 0.00% 18 Missing ⚠️
internal/dao/query_find_create.go 60.97% 13 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #845      +/-   ##
==========================================
- Coverage   27.78%   27.62%   -0.17%     
==========================================
  Files         181      182       +1     
  Lines        7183     7266      +83     
==========================================
+ Hits         1996     2007      +11     
- Misses       5069     5137      +68     
- Partials      118      122       +4     
Flag Coverage Δ
go 27.62% <25.96%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qwqcode qwqcode merged commit a9331b4 into master Apr 30, 2024
5 checks passed
@qwqcode qwqcode deleted the fix/dao branch April 30, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant