Upgrade issue : IntegrityError: null value in column "setting" violates not-null constraint
ISSUE TYPE
Issue after upgrading
SUMMARY
After upgrading from 1.0.1.272 to 1.0.2.0 schedules and running jobs are broken due to db issues.
ENVIRONMENT
- AWX version: 1.0.2.0
- AWX install method: docker on linux
- Ansible version: 2.4.2.0
- Operating System: Centos 7
- Web Browser: Firefox
STEPS TO REPRODUCE
- I dumped Postgres db (just to be sure)
- I downloaded 1.0.2 Release zip and customized installer/inventory file:
dockerhub_version=1.0.2.0and persistentpostgres_data_dir - I deleted running containers and images
- I launched ansible-playbook to install AWX
EXPECTED RESULTS
All my settings and jobs are still available and they work as expected.
ACTUAL RESULTS
I successfully login and every job/configuration/schedule I had is still there. However all my scheduled jobs are not executed and also manual launch fails with no execution. The error in awx_task logs and UI is:
[2018-01-02 11:01:53,017: ERROR/ForkPoolWorker-51] Task awx.main.tasks.awx_periodic_scheduler[d46c61be-a683-4c92-a1b2-b2e6fe6d7fbf] raised unexpected: IntegrityError('null value in column "setting" violates not-null constraint\nDETAIL: Failing row contains (1496, update, 2018-01-02 11:01:53.006371+00, {"next_run": ["2018-01-02 10:45:00+00:00", "2018-01-02 11:15:00+..., , schedule, , null, null).\n',)
Traceback (most recent call last):
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/celery/app/trace.py", line 374, in trace_task
R = retval = fun(*args, **kwargs)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/celery/app/trace.py", line 629, in __protected_call__
return self.run(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/awx/main/tasks.py", line 301, in awx_periodic_scheduler
schedule.save()
File "/usr/lib/python2.7/site-packages/awx/main/models/schedules.py", line 130, in save
super(Schedule, self).save(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/awx/main/models/base.py", line 269, in save
super(PrimordialModel, self).save(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/awx/main/models/base.py", line 164, in save
super(CreatedModifiedModel, self).save(*args, **kwargs)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/base.py", line 808, in save
force_update=force_update, update_fields=update_fields)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/base.py", line 833, in save_base
update_fields=update_fields,
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 193, in send
for receiver in self._live_receivers(sender)
File "/usr/lib/python2.7/site-packages/awx/main/signals.py", line 426, in activity_stream_update
activity_entry.save()
File "/usr/lib/python2.7/site-packages/awx/main/models/activity_stream.py", line 76, in save
super(ActivityStream, self).save(*args, **kwargs)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/base.py", line 808, in save
force_update=force_update, update_fields=update_fields)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/base.py", line 838, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/base.py", line 924, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/base.py", line 963, in _do_insert
using=using, raw=raw)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/query.py", line 1076, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1107, in execute_sql
cursor.execute(sql, params)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
IntegrityError: null value in column "setting" violates not-null constraint
DETAIL: Failing row contains (1496, update, 2018-01-02 11:01:53.006371+00, {"next_run": ["2018-01-02 10:45:00+00:00", "2018-01-02 11:15:00+..., , schedule, , null, null).
ADDITIONAL INFORMATION
Migration seems ok :
[root@awx awx]# awx-manage showmigrations
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
conf
[X] 0001_initial
[X] 0002_v310_copy_tower_settings
[X] 0003_v310_JSONField_changes
[X] 0004_v320_reencrypt
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
django_celery_results
[X] 0001_initial
main
[X] 0001_initial
[X] 0002_squashed_v300_release (18 squashed migrations)
[X] 0003_squashed_v300_v303_updates (14 squashed migrations)
[X] 0004_squashed_v310_release (1 squashed migrations)
[X] 0005_squashed_v310_v313_updates (1 squashed migrations)
[X] 0005a_squashed_v310_v313_updates (1 squashed migrations)
[X] 0005b_squashed_v310_v313_updates (1 squashed migrations)
[X] 0006_v320_release
[X] 0007_v320_data_migrations
[X] 0008_v320_drop_v1_credential_fields
[X] 0009_v330_multi_credential
[X] 0010_saved_launchtime_configs
[X] 0011_blank_start_args
[X] 0012_non_blank_workflow
[X] 0013_move_deprecated_stdout
sessions
[X] 0001_initial
sites
[X] 0001_initial
[X] 0002_alter_domain_unique
social_django
[X] 0001_initial (2 squashed migrations)
[X] 0002_add_related_name (2 squashed migrations)
[X] 0003_alter_email_max_length (2 squashed migrations)
[X] 0004_auto_20160423_0400 (2 squashed migrations)
[X] 0005_auto_20160727_2333 (1 squashed migrations)
[X] 0006_partial
[X] 0007_code_timestamp
[X] 0008_partial_timestamp
sso
[X] 0001_initial
[X] 0002_expand_provider_options
taggit
[X] 0001_initial
[X] 0002_auto_20150616_2121
Any help? Thanks a lot
I just encountered this same issue after upgrading to 1.0.2.0. In my case, I initially upgraded to the latest version, and that failed. So I reverted back, found that I would need to upgrade to 1.0.2.0. In the process I experienced the same exact problem you describe here.
First I noticed that my postresql cluster (I have it segmented from the AWX hosts) was low on disk space.
After cleaning up the disk space, I ran the following query against my awx database:
ALTER TABLE main_activitystream ALTER COLUMN setting DROP NOT NULL;
I then re-ran the ansible installation and everything came up without issue. My templates were able to run, though they were hanging.
I also noticed low disk space on the LVM that docker was stored, so I expanded that LVM and reprovisioned the rabbitmq container. Everything was working fine.
I am sure I had no disk space issues, but thank you for sharing tips and sql statement. As you said I was trying to jump to 2.xxx, but it failed. Then I read that 2.0 was a mandatory step, so I reverted back, and while upgrading to 2.0 I had the issue. However I have noe reinstalled from scratch cause I needed the environment quickly, the configurations I did where a few, so I reconfigured them from the beginning. I close the issue cause I cannot reproduce it in my environment at the moment.