0

In Django app, I'm using Postgres DB. I have two tables where one of them has 76 million records and the other 8.2 million.

I have created a new migration file where in I'm adding a new column to a table in an app and setting default value to 0.

My database is hosted on Ubuntu EC2 instance which has RAM of 8 GB.

When I try to apply the migration using python manage.py migrate app_name migration_file_name, it's throwing below error:

File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.OperationalError: SSL SYSCALL error: EOF detected

I have gone through this solution Postgres SSL SYSCALL error: EOF detected with python and psycopg But not sure if it's memory issue or something else.

Python: 2.7.12
Django 1.11.15
Ubuntu: 18.04
Postgres DB: 10.7

What else could be the issue?

Underoos
  • 4,708
  • 8
  • 42
  • 85

2 Answers2

3

Your query might too large - too many operations. This causes the system to run out of memory.

-1

Adding new column with default value trig a table reconstruction. To avoid that with big table, you can create you migrations in 3 times.

  • Firstly, Create a migration file to add NULLABLE column without default value.
  • Secondly, Create an empty migration that fill this new empty value with excepting default value to all instance with null=True
  • Thirdly, Create a migration that define your column is not nullable with a defaut value
J-E Casta
  • 196
  • 7