Can't do constraint module_certificate_uniq on new base.

Bug #456788 reported by Nicolas DS
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Status tracked in Trunk
Trunk
Fix Released
Undecided
Unassigned
Odoo Server (MOVED TO GITHUB)
Status tracked in Trunk
Trunk
Invalid
Undecided
Unassigned

Bug Description

I am using latest 5.0 version of Open Object Server.

When you create a new database, you will get this:
[2009-10-21 00:52:05,254] DEBUG:orm:creating new column published_version of table ir_module_module
[2009-10-21 00:52:05,262] DEBUG:orm:creating new column reports_by_module of table ir_module_module
[2009-10-21 00:52:05,275] DEBUG:sql:bad query: alter table "ir_module_module" add constraint "ir_module_module_certificate_uniq" unique (certificate)
/home/zyphos/prog/openobject/server/bin/tools/misc.py:741: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  if hasattr(e, 'message'):
/home/zyphos/prog/openobject/server/bin/tools/misc.py:742: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  return ustr(e.message)
[2009-10-21 00:52:05,275] DEBUG:sql:[01]: ERREUR: n'a pas pu créer l'index unique « ir_module_module_certificate_uniq »
[2009-10-21 00:52:05,275] DEBUG:sql:[02]: DETAIL: La table contient des valeurs dupliquées.
[2009-10-21 00:52:05,275] WARNING:orm:[01]: unable to add 'unique (certificate)' constraint on table ir_module_module !
[2009-10-21 00:52:05,276] WARNING:orm:[02]: If you want to have it, you should update the records and execute manually:
[2009-10-21 00:52:05,276] WARNING:orm:[03]: ALTER table ir_module_module ADD CONSTRAINT ir_module_module_certificate_uniq unique (certificate)
[2009-10-21 00:52:06,114] DEBUG:orm:creating new column rml_footer1 of table res_company
[2009-10-21 00:52:06,116] DEBUG:orm:creating new column rml_footer2 of table res_company
[2009-10-21 00:52:06,121] DEBUG:orm:setting default value of new column rml_header of table res_company

Related branches

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Zyphos,

This could be the problem due to your existing modules have a same certificate.

Would you please check and run this query?

select certificate,count(*) from ir_module_module group by certificate having count(*)>2;

If the same certificate (rather than False/Null) appears twice, change the values.

Thanks.

Changed in openobject-server:
status: New → Invalid
Revision history for this message
Nicolas DS (zyphos) wrote :

In fact some modules that I have in list (not installed) have a certificate = "" but not null !

Thoses modules have the problem:
"module_name","author","url","state","latest_version","Short desc"
"comparison";"Tiny";"";"uninstalled";"";"ERP Comparisons"
"event_certificate";"Tiny";"";"uninstalled";"";"Event Certificate"
"document_rule";"Tiny";"";"uninstalled";"";"Extension Module of Document Management System"
"base_module_doc_rst";"Tiny";"";"uninstalled";"";"Module Technical Guide in Restructured Text "
"user_ctg";"Tiny";"";"uninstalled";"";"CTG points Management"
"board_project_portal";"Tiny";"";"uninstalled";"";"Board for project users"
"document_extension";"Tiny";"";"uninstalled";"";"Extension Module of Document Management System"
"wizard_access_rules";"Tiny";"";"uninstalled";"";"Default Access Control"

All of them are made by Tiny, So I suppose that a lot a people are going to have the same issue like me.

Revision history for this message
Harald Oehlmann (harald-oehlmann) wrote :

I suppose, everybody has this issue, but does not follow the warnings in the log.
I suppose, if I fix my installed modules and the constraint, I will not be able to add modules which do not follow this rule.
E.g. a module sets certificate to "" and I try to download the module, this will fail, right ?

So it feels better to me to not set the constraint, right ?

Thanks for any insight about the consequences,
Harald

Revision history for this message
Nicolas DS (zyphos) wrote :

You are absolutely right. But I dislike those parasite warning.

I don't know what is the Pros of having such feature. (Certificate ID)
So duplicated aren't so problematic for me (I don't use Certificate ID). But I guess, it is problematic for Tiny and Tiny's Partners.

Revision history for this message
Harald Oehlmann (harald-oehlmann) wrote :

Hi Jay,
I tried your query and it returned 406 rows with "no contents".
I modified the query to count the rows with certificate equals null:
select certificate,count(*) from ir_module_module group by certificate having certificate is null;
which also returns 406 rows.
So, for me, there are no rows with certificate equal empty string.

It does not look very senseful to put dummy certificates in 406 rows.
I suppose, there is an issue with the design to make this column unique.
IMHO, this report is not invalid, sorry.

Thank you,
Harald

Changed in openobject-server:
status: Invalid → New
Changed in openobject-server:
status: New → Invalid
Revision history for this message
Harald Oehlmann (harald-oehlmann) wrote :

Hi,

now, what I tried is to execute the proposed command in psql:

ALTER table ir_module_module ADD CONSTRAINT ir_module_module_certificate_uniq unique (certificate);

and it was accepted with the comment, that an implicit index is created.

What to do on my SuSE-Linux box:
su postgres; psql -d <data base name>
- enter password
- enter upper command
- enter "\d ir_module_module" to check, if the constraint was added.
- enter "\q" to exit

I have removed the "New" flag of the thread. It is solved for me. I don't know why, but it is as it is.

Thank you,
Harald

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

I changed the logging of sql_db a bit, and this issue now fails the buildbot (http://test.openobject.com/builders/trunkOfficial/builds/1042/steps/create-db/logs/create-db%20%3A%20Traceback).

It's a bug and should be fixed: missing certificates should set the corresponding values to NULL (I don't know about other dbs, but Postgres only checks unicity constraints on non-NULL values), not to an empty value: there are *standard* addons which don't have certificates (analytic, crm_project) so right now this unicity constraint cannot be setup on *any* normal OpenERP install.

Changed in openobject-server:
status: Invalid → New
summary: - [5.0] Can't do constraint module_certificate_uniq on new base.
+ Can't do constraint module_certificate_uniq on new base.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Well looks like the issue is actually that some addons (analytic and crm_project) set certificate to '', which gets set into the db.

Revision history for this message
Anup(SerpentCS) (anup-serpent) wrote :

Hello guys,

This is a definate problem of particular addons(module) which errorneously contains certificate with blank value. Its not at all a problem of server or the constraint certificate_uniq.

Let us know if you face the problem again. Dont forget to enlist the modules.

Thanks.

Revision history for this message
Carlos Sprekelsen (carlos-sprekelsen) wrote :

This same issue has happened today to me (24/08/2010) wit Openerp 5.0.12. I have tried to update modules and I have found 512 modules without certificate. I have manualy addes a value with pgadmin3 to field certificate. Now I do not have any duplicated certificate, but the error still remains. I guess that adding new modules with a blank certificate generates the following error:

Environment Information :
System : Windows-XP-5.1.2600-SP3
OS Name : nt
Operating System Release : XP
Operating System Version : 5.1.2600
Operating System Architecture : 32bit
Operating System Locale : es_ES.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 5.0.12
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/netsvc.py", line 247, in dispatch
    result = LocalService(service_name)(method, *params)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/netsvc.py", line 76, in __call__
    return getattr(self, method)(*params)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/service/web_services.py", line 633, in execute
    return self._execute(db, uid, wiz_id, datas, action, context)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/service/web_services.py", line 613, in _execute
    return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/wizard/__init__.py", line 178, in execute
    res = self.execute_cr(cr, uid, data, state, context)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/wizard/__init__.py", line 73, in execute_cr
    action_res = action(self, cr, uid, data, context)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/base/module/wizard/wizard_update_module.py", line 50, in _update_module
    update, add = pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/base/module/module.py", line 354, in update_list
    'certificate': terp.get('certificate') or None,
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/base/module/module.py", line 512, in create
    id = super(module, self).create(cr, uid, data, context)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/orm.py", line 2853, in create
    cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/sql_db.py", line 77, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/sql_db.py", line 122, in execute
    res = self._obj.execute(query, params)
IntegrityError: llave duplicada viola restricción de unicidad «ir_module_module_certificate_uniq»

I have tried the solutions posted above, but none works for me.

Thanks,
Carlos Sprekelsen

Revision history for this message
Carlos Sprekelsen (carlos-sprekelsen) wrote :

I have removed from ir_module_module the restrction "unique" to ir_module_module_certificate_uniq and it worked again, finding new modules. Afterwards I have added the restriction again:

ALTER table ir_module_module ADD CONSTRAINT ir_module_module_certificate_uniq unique (certificate);

so the table remains as it was.

Carlos Sprekelsen

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hi Carlos,

This could be the problem due to your existing modules have a same certificate.

Would you please check and run this query?

select certificate,count(*) from ir_module_module group by certificate having count(*)>2;

Hope this helps.

Thanks.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.