#36384: update_dimension_fields blocks getting model instances from the database
when the external storage has issues
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: (none)
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 5.1
(models, ORM) | Resolution:
Severity: Normal | worksforme
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):
* easy: 1 => 0
Old description:
> It seems when a height_field or width_field are given, the
> update_dimension_fields is always called on initialization of the model
> instance. Thereby always doing a call to an external database if those
> fields are empty.
>
> This might seem obvious, but it means that when and external storage is
> down, it is not possible anymore to get this Model instance anymore.
>
> For example with S3 issue it might raise:
>
> ```
> ClientError: An error occurred (403) when calling the HeadObject
> operation: Forbidden
> ```
>
> even when I simply want to get the object without the width and height,
> like here:
>
> ```
> UserAvatar.objects.get(user=user).only('id')
> ```
>
> This is in my opinion an unexpected consequence of adding the
> height_field and width_field to an ImageField.
> What do you think, should width and height be lazily loaded somehow?
New description:
It seems when a height_field or width_field are given, the
update_dimension_fields is always called on initialization of the model
instance. Thereby always doing a call to an external database if those
fields are empty.
This might seem obvious, but it means that when and external storage is
down, it is not possible anymore to get this Model instance anymore.
For example with S3 issue it might raise:
`ClientError: An error occurred (403) when calling the HeadObject
operation: Forbidden`
even when I simply want to get the object without the width and height,
like here:
`UserAvatar.objects.get(user=user).only('id')`
This is in my opinion an unexpected consequence of adding the height_field
and width_field to an ImageField.
What do you think, should width and height be lazily loaded somehow?
--
Comment:
The quote code snippet is checking whether the `ImageField` has
height/width fields specified, so that's not the code that will raise an
exception. The report certainly seems plausible, even if it's unclear how
the situation could be improved. It might be the S3 storage backend rather
than Django that should be resilient to network failure.
--
Ticket URL: <https://code.djangoproject.com/ticket/36384#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070196d4891b20-c729e023-44a4-4673-86c2-fb9a7df47a40-000000%40eu-central-1.amazonses.com.