0

每当我尝试运行 zobbpack 时,我都会生成错误:

psycopg2.IntegrityError:“zoid”列中的空值违反非空约束

任何想法是什么导致了这个以及如何解决它?

relstorage 1.5.1,postgres 8,plone 4.2.1.1

2012-12-03 13:18:03,485 [zodbpack] INFO Opening storage (RelStorageFactory)...
2012-12-03 13:18:03,525 [zodbpack] INFO Packing storage (RelStorageFactory).
2012-12-03 13:18:03,533 [relstorage] INFO pack: beginning pre-pack
2012-12-03 13:18:03,533 [relstorage] INFO pack: analyzing transactions committed Mon Nov 26 12:31:54 2012 or before
2012-12-03 13:18:03,536 [relstorage.adapters.packundo] INFO pre_pack: start with gc enabled
2012-12-03 13:18:03,759 [relstorage.adapters.packundo] INFO analyzing references from objects in 97907 new transaction(s)
2012-12-03 13:18:03,761 [relstorage.adapters.scriptrunner] WARNING script statement failed: '\n        INSERT INTO object_refs_added (tid)\n        VALUES (%(tid)s)\n        '; parameters: {'tid': 0L}
2012-12-03 13:18:03,761 [relstorage.adapters.packundo] ERROR pre_pack: failed
Traceback (most recent call last):
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/packundo.py", line 486, in pre_pack
    conn, cursor, pack_tid, get_references)
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/packundo.py", line 580, in _pre_pack_with_gc
    self.fill_object_refs(conn, cursor, get_references)
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/packundo.py", line 387, in fill_object_refs
    self._add_refs_for_tid(cursor, tid, get_references)
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/packundo.py", line 459, in _add_refs_for_tid
    self.runner.run_script_stmt(cursor, stmt, {'tid': tid})
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/scriptrunner.py", line 52, in run_script_stmt
    cursor.execute(stmt, generic_params)
IntegrityError: null value in column "zoid" violates not-null constraint

Traceback (most recent call last):
  File "zodbpack.py", line 86, in <module>
    main()
  File "zodbpack.py", line 78, in main
    skip_prepack=options.reuse_prepack)
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/storage.py", line 1114, in pack
    adapter.packundo.pre_pack(tid_int, get_references)
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/packundo.py", line 486, in pre_pack
    conn, cursor, pack_tid, get_references)
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/packundo.py", line 580, in _pre_pack_with_gc
    self.fill_object_refs(conn, cursor, get_references)
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/packundo.py", line 387, in fill_object_refs
    self._add_refs_for_tid(cursor, tid, get_references)
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/packundo.py", line 459, in _add_refs_for_tid
    self.runner.run_script_stmt(cursor, stmt, {'tid': tid})
  File "/usr/local/lib64/python2.6/site-packages/RelStorage-1.5.1-py2.6.egg/relstorage/adapters/scriptrunner.py", line 52, in run_script_stmt
    cursor.execute(stmt, generic_params)
psycopg2.IntegrityError: null value in column "zoid" violates not-null constraint
4

1 回答 1

1

在没有启用 GC 的情况下运行 zodbpack.py(感谢 Martijn)可以工作并使数据库从 3.8Gb 压缩到 887Mb。

所以我的 zodbpack-conf.xml 看起来像:

<relstorage>
  pack-gc false
  <postgresql>
    dsn dbname='zodb' user='user' host='host' password='password'
  </postgresql>
</relstorage>

我运行它:

python zodbpack.py -d 7 zodbpack-conf.xml

注意:打包完成后,您仍然需要对数据库进行清理以取回空间。我从命令行运行它:

psql zodb postgresuser
zodb=# SELECT pg_database_size('zodb');
zodb=# vacuum full;
zodb=# SELECT pg_database_size('zodb');

有趣的是,当我从 ZMI 控制面板运行 pack 命令时,我仍然得到与以前相同的错误:

Site Error

An error was encountered while publishing this resource.

Error Type: IntegrityError
Error Value: null value in column "zoid" violates not-null constraint 

所以我假设 ZMI 包启用了 GC,并且我的站点数据库中的空值仍然存在问题......

我应该尝试运行一些 SQL 来清除它吗?如果一个对象没有“zoid”值,那么它实际上是不可访问的垃圾吗?这方面的 SQL 示例也很棒:)

于 2012-12-06T04:15:36.950 回答