Skip to content

Fix #8431: Set format_date to False when calling _get_result_meta on mongo backend#8432

Merged
Nusnus merged 3 commits intocelery:mainfrom
asukero:main
Aug 16, 2023
Merged

Fix #8431: Set format_date to False when calling _get_result_meta on mongo backend#8432
Nusnus merged 3 commits intocelery:mainfrom
asukero:main

Conversation

@asukero
Copy link
Copy Markdown
Contributor

@asukero asukero commented Aug 10, 2023

Note: Before submitting this pull request, please review our contributing
guidelines
.

Description

This PR sets format_date argument to False when calling self.get_result_meta in MongoBackend._strore_result to fix task_result collection never been cleaned up when task_expires configuration is set.

Fixes #8431

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 10, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (7b4c4c3) 87.42% compared to head (d40fdd2) 87.42%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8432   +/-   ##
=======================================
  Coverage   87.42%   87.42%           
=======================================
  Files         148      148           
  Lines       18479    18479           
  Branches     3154     3154           
=======================================
  Hits        16155    16155           
  Misses       2034     2034           
  Partials      290      290           
Flag Coverage Δ
unittests 87.39% <ø> (ø)

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

Files Changed Coverage Δ
celery/backends/mongodb.py 98.77% <ø> (ø)

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

@Nusnus
Copy link
Copy Markdown
Member

Nusnus commented Aug 10, 2023

Hey there, thank you for the fix!
Can you add unit tests please?

@Nusnus Nusnus self-requested a review August 10, 2023 15:57
@asukero
Copy link
Copy Markdown
Contributor Author

asukero commented Aug 11, 2023

Since MongoDB queries are mocked inside test_mongodb.py, I can't verify that date_done is inserted as ISODate inside task_result collection instead of string but I added a testcase on test_base.py on get_result_meta with format_date.

I hope it's good for you 🙂

@Nusnus
Copy link
Copy Markdown
Member

Nusnus commented Aug 12, 2023

@asukero

pyupgrade................................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

t/unit/backends/test_base.py:190:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
t/unit/backends/test_base.py:201:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`

Strip unnecessary `# noqa`s..............................................Passed
check for merge conflicts................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
mixed line ending........................................................Passed
isort....................................................................Passed
mypy.....................................................................Passed

Copy link
Copy Markdown
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please fix the lint error?

@asukero
Copy link
Copy Markdown
Contributor Author

asukero commented Aug 16, 2023

Lint error fixed, sorry for the delay

@Nusnus Nusnus added this to the 5.3.x milestone Aug 16, 2023
@Nusnus
Copy link
Copy Markdown
Member

Nusnus commented Aug 16, 2023

The test failures are in test_chain.test_nested_chain_group_lone, this is something that started yesterday and 1) has nothing to do with this PR, 2) appears not to be related to any recent code changes a.k.a something external.

I'll ignore it reviewing this PR then, @auvipy FYI

P.S
The issue is with redis btw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid format of 'date_done' field in celery.task_results with backend mongodb

3 participants