问题描述
我正在使用Django ORM访问PostgreSQL数据库,在极少数情况下,Django会抛出数据库错误,如 django.db.utils.DatabaseError:关系基块299560中的无效页眉83966/84778
。
I'm using the Django ORM to access a PostgreSQL database, and on rare occassions Django will throw a DatabaseError like django.db.utils.DatabaseError: invalid page header in block 299560 of relation base/83966/84778
.
我已经对此进行了研究,这似乎是由于数据库以某种方式损坏了。这非常令人沮丧,因为重新启动时我总是干净地关闭数据库,而且我可以在磁盘驱动器上运行的每一项检查都表明磁盘本身没有问题。因此,我只能得出结论,PostgreSQL实际上并不符合ACID,并且在极少数情况下会破坏我的数据。
I've researched this, and it seems due to the database getting corrupted somehow. This is immensely frustrating, because I've always shutdown the database cleanly when rebooting, and every check I can run on my disk drive says there's nothing wrong with the disk itself. Therefore, I can only conclude that PostgreSQL is not actually ACID compliant and is corrupting my data in rare instances.
我唯一能找到的解决方法是删除并重新创建我的数据库。显然,这并不是真正的解决办法,因为我丢失了所有数据。还有其他方法可以解决此问题,还是应该切换到像MySQL这样更可靠的数据库?
The only fix I've been able to find, is to drop and recreate my database. Obviously, this isn't really a fix, since I'm losing all my data. Is there any other way to resolve this, or should I switch to a more reliable database like MySQL?
我正在Ubuntu 10.04上运行Postgresql-8.4.8。 / p>
I'm running Postgresql-8.4.8 on Ubuntu 10.04.
推荐答案
大多数情况下,您看到的是内存不足或驱动器损坏。 PostgreSQL和MySQL之间的区别在于PostgreSQL看到了它并抱怨了,而MySQL通常只是不断地前进。我认为当机器损坏数据存储时停止的数据库是更可靠的数据库,因为它可以让您立即知道系统存在问题。
Most of the time you see this you either have bad memory or a bad drive. The difference between PostgreSQL and MySQL is that PostgreSQL sees it and complains as it should, while MySQL often just keeps on going with no stopping. I think the db that stops when the machine corrupts the data store is the more reliable db, because it lets you know right up front there are issues with your system.
BTW ,只要硬盘驱动器没有关于fsync的情况,PostgreSQL就可以幸免于紧急关机(将插头拔出计算机的背面)。
BTW, PostgreSQL can survive an emergency shutdown (pull the plug out the back of the machine) just fine as long as the hard drives aren't lying about fsync.
尝试memtest86查看内存是否正常,并执行
Try memtest86 to see if your memory's ok, and do something like
sudo dd if = / dev / sdc1 of = / dev / null
sudo dd if=/dev/sdc1 of=/dev/null
查看是否出现任何错误。 dmesg或消息日志中是否有关于驱动器读写错误的任何内容?
to see if you get any errors. Anything in your dmesg or message logs about drive read write errors?
这篇关于Postgres数据库错误无效的页眉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!