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

Migration base/0074_drop_curated_thumbs.py broken #10747

Closed
etj opened this issue Mar 7, 2023 · 0 comments
Closed

Migration base/0074_drop_curated_thumbs.py broken #10747

etj opened this issue Mar 7, 2023 · 0 comments
Assignees
Labels
4.0.x 4.1.x major A high priority issue which might affect a lot of people or large parts of the codebase

Comments

@etj
Copy link
Contributor

etj commented Mar 7, 2023

The migration base/migrations/0074_drop_curated_thumbs.py may fail due to a race condition.

Migrations may fail with:

django4gn4_clean       |   Applying base.0073_resourcebase_thumbnail_path... OK
django4gn4_clean       |   Applying base.0074_drop_curated_thumbs...Error during updating resource: 'NoneType' object has no attribute 'objects'
django4gn4_clean       | Error during updating resource: 'NoneType' object has no attribute 'objects'
django4gn4_clean       | Error during updating resource: 'NoneType' object has no attribute 'objects'
[... repeated hundreds of times...]

By running the migration code by hand, it seems that the get_real_instance method is failing:

In [6]: resource = ResourceBase.objects.filter(id=resource_id).first()

In [7]: resource
Out[7]: <ResourceBase: Buffer Zone MaB Unesco Po Grande 2019 (Distretto Po)>

In [8]: resource.get_real_instance()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[8], line 1
----> 1 resource.get_real_instance()

File /usr/local/lib/python3.10/site-packages/polymorphic/models.py:173, in PolymorphicModel.get_real_instance(self)
    171 if real_model == self.__class__:
    172     return self
--> 173 return real_model.objects.db_manager(self._state.db).get(pk=self.pk)

AttributeError: 'NoneType' object has no attribute 'objects'

In [9]: resource.get_real_instance_class()

In [10]: type(resource)
Out[10]: geonode.base.models.ResourceBase

I noted that the layers migrations were not run, so the source code had a layers.Dataset class, where the DB still had the layers.Layer table.

Running by hand the migrations in the layers app and then running the base migrations, everything runs smoothly.

@etj etj mentioned this issue Mar 7, 2023
12 tasks
etj added a commit to etj/geonode that referenced this issue Mar 7, 2023
@etj etj self-assigned this Mar 7, 2023
giohappy pushed a commit that referenced this issue Mar 8, 2023
* #10747 Migration base/0074_drop_curated_thumbs.py broken

* #10752 Migration base.0067_resourcebase_storetype broken

* #10751 Migration upload/0033_auto_20210527_1520 broken

* #10753 Migration layers.0040_dataset_ows_url broken

* #10755 Some other migrations broken
giohappy pushed a commit that referenced this issue Mar 8, 2023
* #10747 Migration base/0074_drop_curated_thumbs.py broken

* #10752 Migration base.0067_resourcebase_storetype broken

* #10751 Migration upload/0033_auto_20210527_1520 broken

* #10753 Migration layers.0040_dataset_ows_url broken

* #10755 Some other migrations broken
@afabiani afabiani added major A high priority issue which might affect a lot of people or large parts of the codebase 4.0.x 4.1.x labels Mar 8, 2023
@afabiani afabiani closed this as completed Mar 8, 2023
giohappy added a commit that referenced this issue Mar 8, 2023
* #10747 Migration base/0074_drop_curated_thumbs.py broken

* #10752 Migration base.0067_resourcebase_storetype broken

* #10751 Migration upload/0033_auto_20210527_1520 broken

* #10753 Migration layers.0040_dataset_ows_url broken

* #10755 Some other migrations broken

Co-authored-by: Emanuele Tajariol <[email protected]>
github-actions bot pushed a commit that referenced this issue Mar 8, 2023
* #10747 Migration base/0074_drop_curated_thumbs.py broken

* #10752 Migration base.0067_resourcebase_storetype broken

* #10751 Migration upload/0033_auto_20210527_1520 broken

* #10753 Migration layers.0040_dataset_ows_url broken

* #10755 Some other migrations broken

Co-authored-by: Emanuele Tajariol <[email protected]>
(cherry picked from commit 7242030)
giohappy added a commit that referenced this issue Mar 8, 2023
* #10747 Migration base/0074_drop_curated_thumbs.py broken

* #10752 Migration base.0067_resourcebase_storetype broken

* #10751 Migration upload/0033_auto_20210527_1520 broken

* #10753 Migration layers.0040_dataset_ows_url broken

* #10755 Some other migrations broken

Co-authored-by: Emanuele Tajariol <[email protected]>
(cherry picked from commit 7242030)

Co-authored-by: Giovanni Allegri <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.0.x 4.1.x major A high priority issue which might affect a lot of people or large parts of the codebase
Projects
None yet
Development

No branches or pull requests

2 participants