Merge lp:~sinzui/launchpad/missing-potmsgset into lp:launchpad
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | j.c.sackett on 2012-11-15 | ||||
| Approved revision: | no longer in the source branch. | ||||
| Merged at revision: | 16276 | ||||
| Proposed branch: | lp:~sinzui/launchpad/missing-potmsgset | ||||
| Merge into: | lp:launchpad | ||||
| Diff against target: |
39 lines (+7/-2) 1 file modified
lib/lp/translations/utilities/translation_import.py (+7/-2) |
||||
| To merge this branch: | bzr merge lp:~sinzui/launchpad/missing-potmsgset | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| j.c.sackett (community) | 2012-11-15 | Approve on 2012-11-15 | |
|
Review via email:
|
|||
Commit Message
Ensure POTMsgSets are in the db during poimport.
Description of the Change
The rosetta-poimport script is violating referential integrity:
2011-10-20 23:16:23 ERROR insert or update on table "translationmes
violates foreign key constraint "translationmes
DETAIL: Key (potmsgset)
-- Slovenian (sl) translation of kaddressbook in
Ubuntu Oneiric package "kdepim" (id 5905106)
Full traceback: http://
A query some 12 hours after this particular failure shows that the
highest used id in potmsgset is 11787759. So the problematic id is quite
a new one.
-------
RULES
Pre-
* We do not know for certain why the POTMsgSet is not yet in the DB.
* We have confirmed that the UnusedPOTMsgSet
with poimport, but getOrCreatePOTM
exist (in code) when it is needed.
* Both processes are iterating over a collection and committing at
each loop. They do change the DB as both run.
* We Updated UnusedPOTMsgSet
the loop if it suddenly became used.
* In 13 lines of code and a few milliseconds pass between the point
where getOrCreatePOTM
POTMsgSet
impending query will work. But the oops shows that the POTMsgSet
did not arrive in time. Within those 13 lines of code, a
Translati
current translation. The OOPS is actually about the
act of creating the TranslationMessage, but we do not see this
DB error until we execute more lines of code working with it and
its POTMsgSet and the ORM decides to flush.
* There are rules to flush the top-level objects (POFile and
POTemplate) after they are created. There are also rules to
alter the flush order of messages to ensure the act of reassignment
does not cause a unique key violation. But the intermediate
POTMsgSet is not explicitly flushed.
* Else where in Lp the POTMsgSet is explicitly flushed when it is
created or modified. In fact the same list of modified POTMsgSet
attrs get flushed by the testing factory as is changed by poimport.
* There are two places to call flush() to ensure the POTMsgSet is in
the DB. 1, immediately after the change to the attrs as is done
else where, or 2, in storeTranslatio
* The call to storeTranslatio
call to flush would be added, so the intent of the method is
to get all the data into the DB -- Add a call to flush() in
an early exit.
QA
* None. We do not know how to create the issue. This code just ensures
the case cannot happen.
LoC
* I have a 3000 line credit this week.
LINT
lib/
TEST
./bin/test -vv lp.translations
IMPLEMENTATION
Added a call to flush() the ORM when it is certain the data needs to go
to the DB. Cleanup lint.
lib/

Thank you.