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: rollback logs warning on clean sessions [DIA-40867] #52

Merged
merged 3 commits into from
Apr 12, 2022

Conversation

vicrep
Copy link
Contributor

@vicrep vicrep commented Apr 12, 2022

Description

Currently, when fastapi-sqla encounters an http error, it will rollback the session, regardless of the error, and log an associated warning. However, this causes a lot of log noise for inconsequential rollbacks (e.g. 404s will also trigger this warning).

This takes an optimistic approach and checks if a session is dirty (which could but doesn't necessarily indicate that data will be written to DB) before logging the warning, effectively silencing the log when a rollback is expected to be no-op.

See https://app.datadoghq.com/logs?query=app%3Anotepad%20env%3Adev-ca2%20scope%3Acore&agg_m=count&agg_t=count&event=AQAAAYAewq6X7ACj4AAAAABBWUFld3JUdEFBQmxxbk1TTEppcE1nQUk&index=main&from_ts=1649769234000&to_ts=1649783634000&live=false for an example of such log that this would silence.

@vicrep vicrep changed the title fix: rollback warning on clean sessions fix: rollback logs warning on clean sessions Apr 12, 2022
@vicrep vicrep requested a review from hadrien April 12, 2022 17:47
@vicrep vicrep requested a review from hadrien April 12, 2022 18:15
@codecov
Copy link

codecov bot commented Apr 12, 2022

Codecov Report

Merging #52 (15adb4d) into master (544d6b4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master      #52   +/-   ##
=======================================
  Coverage   99.35%   99.35%           
=======================================
  Files           4        4           
  Lines         310      312    +2     
  Branches       21       22    +1     
=======================================
+ Hits          308      310    +2     
  Misses          2        2           
Flag Coverage Δ
sqlalchemy1.3-asyncpg-aws_rds_iam 72.43% <100.00%> (+0.17%) ⬆️
sqlalchemy1.3-asyncpg-noaws_rds_iam 70.51% <100.00%> (+0.19%) ⬆️
sqlalchemy1.3-noasyncpg-aws_rds_iam 72.11% <100.00%> (+0.17%) ⬆️
sqlalchemy1.3-noasyncpg-noaws_rds_iam 70.19% <100.00%> (+0.19%) ⬆️
sqlalchemy1.4-asyncpg-aws_rds_iam 94.55% <100.00%> (+0.03%) ⬆️
sqlalchemy1.4-asyncpg-noaws_rds_iam 92.62% <100.00%> (+0.04%) ⬆️
sqlalchemy1.4-noasyncpg-aws_rds_iam 78.20% <100.00%> (+0.14%) ⬆️
sqlalchemy1.4-noasyncpg-noaws_rds_iam 76.28% <100.00%> (+0.15%) ⬆️

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

Impacted Files Coverage Δ
fastapi_sqla/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8eac166...15adb4d. Read the comment docs.

@vicrep vicrep changed the title fix: rollback logs warning on clean sessions fix: rollback logs warning on clean sessions [DIA-40867] Apr 12, 2022
@vicrep vicrep merged commit 282d8fc into master Apr 12, 2022
@vicrep vicrep deleted the fix/quiet-rollback branch April 12, 2022 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants