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

BUG FIX: Fixed temp_file flush issue for cloud storage in cache.py #4118

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

ML-Guy
Copy link
Contributor

@ML-Guy ML-Guy commented Jan 5, 2022

Issue Summary: File downloaded from cloud storage is not flushed. In case of lot of files, for some files, changes don't reflect in the actual physical file. Actual file is later accessed by filename, which leads to read error.

Issue Error logs:

2022-01-05 09:54:14,992 DEBG 'runserver' stderr output:
[Wed Jan 05 09:54:14.992125 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] [2022-01-05 09:54:14,991] ERROR cvat.server.task_12: cannot get requested data type: chunk, number: 0, quality: Quality.COMPRESSED
[Wed Jan 05 09:54:14.992147 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] Traceback (most recent call last):
[Wed Jan 05 09:54:14.992152 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/cache.py", line 96, in prepare_chunk_buff
[Wed Jan 05 09:54:14.992156 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     if checksum and not md5_hash(source_path) == checksum:
[Wed Jan 05 09:54:14.992159 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/utils.py", line 100, in md5_hash
[Wed Jan 05 09:54:14.992163 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     frame = Image.open(frame, 'r')
[Wed Jan 05 09:54:14.992166 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/opt/venv/lib/python3.8/site-packages/PIL/Image.py", line 3023, in open
[Wed Jan 05 09:54:14.992186 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     raise UnidentifiedImageError(
[Wed Jan 05 09:54:14.992189 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] PIL.UnidentifiedImageError: cannot identify image file '/tmp/cvat_041w7vsimages#0089c635-ae5f-49d7-baa5-a4d75f0412ca.png'
[Wed Jan 05 09:54:14.992192 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]
[Wed Jan 05 09:54:14.992196 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] During handling of the above exception, another exception occurred:
[Wed Jan 05 09:54:14.992199 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]

2022-01-05 09:54:14,992 DEBG 'runserver' stderr output:
[Wed Jan 05 09:54:14.992202 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] Traceback (most recent call last):
[Wed Jan 05 09:54:14.992205 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/views.py", line 689, in data
[Wed Jan 05 09:54:14.992208 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     buff, mime_type = frame_provider.get_chunk(data_id, data_quality)
[Wed Jan 05 09:54:14.992211 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/frame_provider.py", line 167, in get_chunk
[Wed Jan 05 09:54:14.992215 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     return self._loaders[quality].get_chunk_path(chunk_number, quality, self._db_data)
[Wed Jan 05 09:54:14.992218 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/cache.py", line 32, in get_buff_mime
[Wed Jan 05 09:54:14.992221 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     chunk, tag = self.prepare_chunk_buff(db_data, quality, chunk_number)
[Wed Jan 05 09:54:14.992224 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/cache.py", line 113, in prepare_chunk_buff
[Wed Jan 05 09:54:14.992227 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     raise Exception(msg)
[Wed Jan 05 09:54:14.992231 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] Exception: cannot identify image file '/tmp/cvat_041w7vsimages#0089c635-ae5f-49d7-baa5-a4d75f0412ca.png'
[Wed Jan 05 09:54:14.992414 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] ERROR - 2022-01-05 09:54:14,991 - views - cannot get requested data type: chunk, number: 0, quality: Quality.COMPRESSED
[Wed Jan 05 09:54:14.992425 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] Traceback (most recent call last):

Motivation and context

How has this been tested?

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below)
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT

Issue Summary: File downloaded from cloud storage is not flushed. In case of lot of files, for some files, changes don't reflect in the actual physical file. Actual file is later accessed by filename, which leads to read error.

Issue Error logs:

```
2022-01-05 09:54:14,992 DEBG 'runserver' stderr output:
[Wed Jan 05 09:54:14.992125 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] [2022-01-05 09:54:14,991] ERROR cvat.server.task_12: cannot get requested data type: chunk, number: 0, quality: Quality.COMPRESSED
[Wed Jan 05 09:54:14.992147 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] Traceback (most recent call last):
[Wed Jan 05 09:54:14.992152 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/cache.py", line 96, in prepare_chunk_buff
[Wed Jan 05 09:54:14.992156 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     if checksum and not md5_hash(source_path) == checksum:
[Wed Jan 05 09:54:14.992159 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/utils.py", line 100, in md5_hash
[Wed Jan 05 09:54:14.992163 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     frame = Image.open(frame, 'r')
[Wed Jan 05 09:54:14.992166 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/opt/venv/lib/python3.8/site-packages/PIL/Image.py", line 3023, in open
[Wed Jan 05 09:54:14.992186 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     raise UnidentifiedImageError(
[Wed Jan 05 09:54:14.992189 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] PIL.UnidentifiedImageError: cannot identify image file '/tmp/cvat_041w7vsimages#0089c635-ae5f-49d7-baa5-a4d75f0412ca.png'
[Wed Jan 05 09:54:14.992192 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]
[Wed Jan 05 09:54:14.992196 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] During handling of the above exception, another exception occurred:
[Wed Jan 05 09:54:14.992199 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]

2022-01-05 09:54:14,992 DEBG 'runserver' stderr output:
[Wed Jan 05 09:54:14.992202 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] Traceback (most recent call last):
[Wed Jan 05 09:54:14.992205 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/views.py", line 689, in data
[Wed Jan 05 09:54:14.992208 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     buff, mime_type = frame_provider.get_chunk(data_id, data_quality)
[Wed Jan 05 09:54:14.992211 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/frame_provider.py", line 167, in get_chunk
[Wed Jan 05 09:54:14.992215 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     return self._loaders[quality].get_chunk_path(chunk_number, quality, self._db_data)
[Wed Jan 05 09:54:14.992218 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/cache.py", line 32, in get_buff_mime
[Wed Jan 05 09:54:14.992221 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     chunk, tag = self.prepare_chunk_buff(db_data, quality, chunk_number)
[Wed Jan 05 09:54:14.992224 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]   File "/home/django/cvat/apps/engine/cache.py", line 113, in prepare_chunk_buff
[Wed Jan 05 09:54:14.992227 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868]     raise Exception(msg)
[Wed Jan 05 09:54:14.992231 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] Exception: cannot identify image file '/tmp/cvat_041w7vsimages#0089c635-ae5f-49d7-baa5-a4d75f0412ca.png'
[Wed Jan 05 09:54:14.992414 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] ERROR - 2022-01-05 09:54:14,991 - views - cannot get requested data type: chunk, number: 0, quality: Quality.COMPRESSED
[Wed Jan 05 09:54:14.992425 2022] [wsgi:error] [pid 330:tid 139683931096832] [remote 172.20.0.2:56868] Traceback (most recent call last):
```
@ML-Guy ML-Guy requested a review from nmanovic as a code owner January 5, 2022 19:23
@ML-Guy ML-Guy changed the title Fixed temp_file flush issue for cloud storage in cache.py BUG FIX: Fixed temp_file flush issue for cloud storage in cache.py Jan 7, 2022
Copy link
Contributor

@Marishka17 Marishka17 left a comment

Choose a reason for hiding this comment

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

@ML-Guy, Thanks for the contribution.

@nmanovic nmanovic merged commit 59f0b3b into cvat-ai:develop Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants