Commit Graph

67 Commits

Author SHA1 Message Date
Raphael Collet 980f6fc4b1 [IMP] registry: avoid every direct access registry.db, and rename attribute as registry._db
bzr revid: rco@openerp.com-20140409133515-x2ywcm0d2qkdq3hq
2014-04-09 15:35:15 +02:00
Raphael Collet e5e00e4c0a [IMP] registry: now cursor() simply returns a cursor, which may itself be used as a context manager
bzr revid: rco@openerp.com-20140409095604-joh9dt0qkma12ykm
2014-04-09 11:56:04 +02:00
Raphael Collet f0fd48c44a [IMP] http tests: implement a test cursor that keeps a transaction open accross requests
- TestCursor subclasses Cursor, and simulates commit and rollback with savepoints
 - the registry manages a test mode, in which it only uses the test cursor
 - a reentrant lock forces the serialization of parallel requests

bzr revid: rco@openerp.com-20140408151736-j0guy68i2wjexy3d
2014-04-08 17:17:36 +02:00
Raphael Collet 6bc60505f4 [IMP] registry: add method get_cursor() to simply retrieve a new cursor, and refactor code to use it
bzr revid: rco@openerp.com-20140408125122-ki0zmin3m21k2itd
2014-04-08 14:51:22 +02:00
Raphael Collet b49f536baf [IMP] tests.common: turn class methods into instance methods (this will ease some future refactoring)
bzr revid: rco@openerp.com-20140408114936-jfagg4qvft8bk3ms
2014-04-08 13:49:36 +02:00
Raphael Collet 81b84c62b1 [IMP] registry: switch for a dummy lock only during the execution of http tests
bzr revid: rco@openerp.com-20140408094513-ahtwod1q17ijohbg
2014-04-08 11:45:13 +02:00
Antony Lesuisse c8324bafcc [IMP] phantomjs testing
- avoid dbmanager by presetting db in the test session
- correctly handle login option
- serialize test cursor access

bzr revid: al@openerp.com-20140216212222-4o6x9uljyua3g1og
2014-02-16 22:22:22 +01:00
Antony Lesuisse 278ed718e9 new test execution engine
remove deprecated zipfile support
add preload_registry option when server is running
allow registries to be used in contruction in test mode
add a rollback test case for http tests
add a phantomjs helper

bzr revid: al@openerp.com-20140209004005-p5pwym4sqc23vw5b
2014-02-09 01:40:05 +01:00
Christophe Simonis a69f789b41 [MERGE] forward port of branch 7.0 up to revid 5224 chs@openerp.com-20140206105141-7e8bv8ordqqsswh7
bzr revid: dle@openerp.com-20140205105045-j95kduyjiq83e57z
bzr revid: dle@openerp.com-20140114173613-ruxye1m7fxtcjfim
bzr revid: dle@openerp.com-20140116161158-u95vcs3os4tk2zob
bzr revid: dle@openerp.com-20140121172737-gzawfi3ssg7xifef
bzr revid: chs@openerp.com-20140129094554-c3abc8x3qz9mpszr
bzr revid: chs@openerp.com-20140129140159-9vwkpr078shoonum
bzr revid: chs@openerp.com-20140206110220-myn57cryam1y4k9v
2014-02-06 12:02:20 +01:00
Denis Ledoux 4aeba0c12e [FIX] modules: multi worker signaling initialize variables before loading registry
bzr revid: dle@openerp.com-20140121171836-dxs7cvqcd9nxytu1
2014-01-21 18:18:36 +01:00
Olivier Dony 212b6bc480 [FIX] modules: set initial values for multi-process signaling to None to avoid missing events
For fresh databases, the signaling sequences in the
database stays at 1 until the installation of the
first module. If several workers are hit for this
database before the first module is installed,
this database registry will be loaded with a signaling
sequence of 1. Since  was the default value, any
signal received by workers in this state was ignored 
because they thought the registry was previously
not loaded.
Using None to indicate an  sequence value
is more accurate and avoids this error

bzr revid: dle@openerp.com-20140116151157-3zlyrg48xqn2lkd0
2014-01-16 16:11:57 +01:00
Denis Ledoux 6fd552c3ce [MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 5139 rev-id: dle@openerp.com-20131121132305-qjlclgz5v9tze1fr
bzr revid: odo@openerp.com-20131120102545-2tlp031yib6viz35
bzr revid: chs@openerp.com-20131120161708-c8sbom592moukwxw
bzr revid: dle@openerp.com-20131121155457-lh7fzouk2upeiu16
2013-11-21 16:54:57 +01:00
Martin Trigaux 7ae9e1c86d [FIX] registry: missing a threading.RLock in RegistryManager.get():
if no registry exists and several calls to RegistryManager.get() are called at the same time
by several threads, several registries will be created one after the other and only the last
one will be kept in cls.registries (courtesy of Guewen Baconnier (Camptocamp)

Invert behaviour of commit 3685 because, at that time, the new trigger the schedule_cron_jobs method which ran another lock and called get on the registry. We had a deadlock with the cron. This is no longer the case as we don't call the same method at the end of the creation of the registry and it does not trigger a lock

bzr revid: mat@openerp.com-20131114144401-k00podawlem7cjd1
2013-11-14 15:44:01 +01:00
Olivier Dony 54f740960e [MERGE] Forward-port of latest saas-1 bugfixes, up to rev. 4912 rev-id: odo@openerp.com-20131016110621-36vvlpn8dgsabyt1
bzr revid: odo@openerp.com-20131016111800-jjybreg62bwz61zn
2013-10-16 13:18:00 +02:00
Olivier Dony 8ac110c4dd [MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 5098 rev-id: odo@openerp.com-20131011123914-7zuvd9mch21yxgj8
bzr revid: dle@openerp.com-20131009131902-a93nsbou4w8y0vlx
bzr revid: chs@openerp.com-20131009175454-j06y1ngylfbqyrpj
bzr revid: dle@openerp.com-20130918160049-fo88fl7uyhfoofkv
bzr revid: dle@openerp.com-20130924130544-kmkyr0d73cusvdav
bzr revid: odo@openerp.com-20131011134433-nyfjipvlql4xu127
2013-10-11 15:44:33 +02:00
Olivier Dony 088cb0255d [FIX] registry: restore `elif` changed to `if` in previous commit, for better readability (no effect)
This should have no effect because when the first `if`
is entered a new registry is instantiated with
the default value for base_cache_signaling_sequence
set to 1, preventing entering the next `if` even
without `elif`.

bzr revid: odo@openerp.com-20131011123914-7zuvd9mch21yxgj8
2013-10-11 14:39:14 +02:00
Olivier Dony 78579d289b [FIX] registry: avoid discarding registry or cache when the registry is fresh
When the sequence value is 1 it means that either:
 - the registry was just instantiated, so there is no
   reason to reload it immediately, the real checks will
   start at next request
 - the db was just created with new sequences set to 1,
   so there has been no change to reload

In both cases there is no good reason to reload the
registry, and it is actually a performance killer,
especially for cron workers that keep iterating on
the list of databases.

bzr revid: odo@openerp.com-20131011100313-4bud8e9xq2afp9z7
2013-10-11 12:03:13 +02:00
Guewen Baconnier 9c769c9a99 [FIX] missing a threading.RLock in RegistryManager.get():
if no registry exists and several calls to RegistryManager.get() are called at the same time
by several threads, several registries will be created one after the other and only the last
one will be kept in cls.registries

lp bug: https://launchpad.net/bugs/1238560 fixed

bzr revid: guewen.baconnier@camptocamp.com-20131011092632-b267vhdadh7q9som
2013-10-11 11:26:32 +02:00
niv-openerp ac1d0742a0 [IMP] minor improvement in RegistryManager, useful for web client
bzr revid: nicolas.vanhoren@openerp.com-20130619105335-w3xftm6g0llh1ade
2013-06-19 12:53:35 +02:00
Raphael Collet 05851d21ba [MERGE] from trunk
bzr revid: rco@openerp.com-20130411073017-x6e4h8xbvmy3ofdw
2013-04-11 09:30:17 +02:00
Vo Minh Thu 307ca374d6 [MERGE] forward merge 7.0 until revision 4919.
bzr revid: vmt@openerp.com-20130404130704-24vsmczw34cssytd
2013-04-04 15:07:04 +02:00
Raphael Collet b99398fa29 [IMP] registry: make class Registry inherit from abstract class collections.Mapping
bzr revid: rco@openerp.com-20130404102524-innz9qu824yfds4b
2013-04-04 12:25:24 +02:00
Raphael Collet d3657d858f [IMP] registry: add convenience operators ('in' and 'iter') on registry objects
bzr revid: rco@openerp.com-20130329135853-woi26cl2yiofv7h2
2013-03-29 14:58:53 +01:00
Vo Minh Thu b08d7ef6bd [REF] ir.actions.report.xml: register_all do not make sense any more:
auto=True reports are looked up in the database for each rendering, so they do
no have to be in the report registry any longer.
auto=False reports will register themselves but at this point
they can be updated to use the new `parser` XML attribute.

bzr revid: vmt@openerp.com-20130322153955-s6nyux2pyez6c01w
2013-03-22 16:39:55 +01:00
Vo Minh Thu e746cb1654 [FIX] registry: fix a bug where RegistryManager.new() could return an out-of-date registry.
bzr revid: vmt@openerp.com-20130212085311-o53wv7yful39kktd
2013-02-12 09:53:11 +01:00
Olivier Dony 4fd1bc7b3c [IMP] cron: remove useless pooljobs and schedule_cron_jobs methods
The pooljobs and scheduled_cron_jobs stuff was only used to
delay the processing of cron jobs until after the registry
was fully loaded. However this is already the case because
RegistryManager.new() only sets the flag at the end of the
init step.
The flag was named `registry.cron` but simply meant that the
registry was fully loaded and ready, so it is simpler to
rename it to `registry.ready`.

In multiprocess mode this flag is enterily irrelevant
so there is no need to selectively set it to True or
False. `registry.ready` is simpler.

bzr revid: odo@openerp.com-20121221133751-h4x670vblfr3d09e
2012-12-21 14:37:51 +01:00
Olivier Dony e373ac5aeb [MERGE] *: fix/rationalize db logging to avoid incorrect values during logging
The setting/clearing of the tracking were not done
consistently, causing log messages that appeared
to come from one database while coming from another
one or none at all.

The tracker is now set at the earliest points
of request handling as possible:
- in web, when creating WebRequests (dbname, uid)
- at RPC dispatching in server (uid)
- at cron job acquisition in CronWorker (dbname)
- at Registry acquisition in RegistryManager (dbname)


The tracker is cleared at the very entrance of
the request in the WSGI `application`, ensuring
that no logging is produced with an obsolete
db name. (It cannot be cleared at the end of
the request handling because the werkzeug
wrapper outputs more logging afterwards)

bzr revid: odo@openerp.com-20130301182510-1fqo9o8di0jw95b5
2013-03-01 19:25:10 +01:00
Olivier Dony 9770caedf3 [FIX] registry: another pass of cleanup for registry signaling
Some important points to consider:
 - signaling should be done after any schema alteration (including module [un]installation),
   service registration (e.g. reports)
 - the changes need to be committed to the database *before* signaling, otherwise an
   obvious race condition occurs during reload by other workers
 - any call to restart_pool() must be considered a possible candidate for
   signaling, and the 2 above conditions must be checked

The number of explicit calls was reduced by forcing the signaling at the end of
Registry.new() in case `update_module` was passed as True. In that situation
we always want to signal the changes - so all the redundant signaling calls
can be centralized. We can also assume that the relevant changes have already
been committed at that point, otherwise the registry update would not
have worked in the first place.
This means that there is no need for explicit signaling anymore everytime
`restart_pool` is called with `update_module=True`.

Some missing cr.commit() and explicit signaling calls were added or
moved to the right place. As a reminder: signaling must be done
*after* committing the changes, and usually *after* reloading the
registry on the current worker.

bzr revid: odo@openerp.com-20130301143203-e2csf5pkllwhmwqs
2013-03-01 15:32:03 +01:00
Olivier Dony db81edc287 [FIX] *: fix/rationalize db logging to avoid incorrect values during logging
The setting/clearing of the tracking were not done
consistently, causing log messages that appeared
to come from one database while coming from another
one or none at all.

The tracker is now set at the earliest points
of request handling where we can:
- in web client, when creating WebRequests (dbname, uid)
- at RPC dispatching in server (uid)
- at cron job acquisition in CronWorker (dbname)
- at Registry acquisition in RegistryManager (dbname)


The tracker is cleared at the very entrance of
the request in the WSGI `application`, ensuring
that no logging is produced with an obsolete
db name. (It cannot be cleared at the end of
the request handling because the werkzeug
wrapper outputs more logging afterwards)

bzr revid: odo@openerp.com-20130301120744-jfitcmze2jldecod
2013-03-01 13:07:44 +01:00
Olivier Dony 9f77d2e2f4 [FIX] orm,registry: properly check m2o FKs during model update + fix some models `auto_init`ed multiple times
The case where no constraint existed at all was not working,
and after fixing it, the ORM started to re-create the same
constraints multiple times for some modules. This was for
models that are split within a module (such as res.users in
base, which is made of several small classes): all the
partial models were going through _auto_init instead
of only the final one - doing useless extra work.
      
Unfortunately establishing the FK happens before the
XML data files are loaded, so a number of FK and
NOT NULL constraints failed to apply due to missing
tables/records. base.sql had to be extended a bit
to cover these cases in a minimalist fashion

bzr revid: odo@openerp.com-20121217214645-av9n003yzterhujw
2012-12-17 22:46:45 +01:00
Vo Minh Thu 08a082f63f [FIX] registry: Set the fields_by_model attribute in __init__(), use None to flag non-existing fields-per-model cache.
bzr revid: vmt@openerp.com-20121214141114-em9r66e3sfy21t2r
2012-12-14 15:11:14 +01:00
Antony Lesuisse ae45df93a4 misc
bzr revid: al@openerp.com-20121209190543-83hmvyfcu1af7wiv
2012-12-09 20:05:43 +01:00
Antony Lesuisse f4977b1f44 cron registrymanager removal
bzr revid: al@openerp.com-20121209175300-rhwf9n0y29o7ct19
2012-12-09 18:53:00 +01:00
Antony Lesuisse 42f292af93 cron cleanup, back to the Kernighan KISS roots 1min poll time, rely only on database, multiprocess/multiserver ready.
Nota: If we replace sequence signaling for cache invalidation with pg
listen/notify in the future, we will use the same mechanism for more accurate
cron timing.

bzr revid: al@openerp.com-20121209170447-zs0k3jazokylwvar
2012-12-09 18:04:47 +01:00
Antony Lesuisse 3d2a09a973 multiprocessing signaling manually backported from 6.1
bzr revid: al@openerp.com-20121208181151-lfy956ysnok5b5hf
2012-12-08 19:11:51 +01:00
Vo Minh Thu 38336593f7 [IMP] registry: the `assertion_report` is now a registry attribute.
This allow us to report failure or success by inspecting the registry.

bzr revid: vmt@openerp.com-20121102134732-5uy1vp59mp1bxgjs
2012-11-02 14:47:32 +01:00
Christophe Simonis 3e251640d2 [IMP] add cursor() contextmanager on registry
bzr revid: chs@openerp.com-20120813150501-txkrphi7hyp2tgl1
2012-08-13 17:05:01 +02:00
Olivier Dony 2126f83a35 [IMP] modules, ir.ui.view: improve view validation + avoid validation errors during updates
As of 7.0, RNG validation is not possible for form views
that have a version attribute equal to "7.0", due to the
allowed usage of HTML syntax mixed with the regular OpenERP
view syntax. RNG validation is still enabled for regular
form views (@version missing or less than "7.0"), and for
all other views types.
Validation of 7.0 form views should be improved with the
addition of an assertion-based schema, still to be done.
 
The above is also complemented with an explicit call to fields_view_get()
during view installation, in order to immediately verify
that the updated view hierarchy does not cause any
issue when loaded along with its related views (i.e
parent and siblings, for inheriting views).
In addition to that, fields_view_get() will now only
consider loading views that belong to modules that have
already been loaded. This avoids a lot of validation errors
during a module update operation, which runs on top of
an existing database with all previous views visible,
even those whose module is not loaded yet.

bzr revid: odo@openerp.com-20120611122758-qcw9xdhupl24busq
2012-06-11 14:27:58 +02:00
Vo Minh Thu f22f2fc770 [IMP] openerp.{modules,osv}: _logger with fully qualified module name.
bzr revid: vmt@openerp.com-20120124124252-91g3ysf33zsq4nhd
2012-01-24 13:42:52 +01:00
Xavier Morel 6d70751dd7 [FIX] deadlock between crons scheduling and new registry initialization creation
bzr revid: xmo@openerp.com-20110930150026-m0h99fqk6qgne8i1
2011-09-30 17:00:26 +02:00
Olivier Dony f5fdb9f494 [FIX] cron/registry: typo
bzr revid: odo@openerp.com-20110928235048-ssfqeu7ug35isyfk
2011-09-29 01:50:48 +02:00
Olivier Dony f2b9b58fd3 [IMP] cron: misc renaming and minor changes to improve reviewability ;-)
bzr revid: odo@openerp.com-20110928224429-up0k4ts3cdks1u2s
2011-09-29 00:44:29 +02:00
Olivier Dony e7601e68cb [MERGE] sync with latest trunk
bzr revid: odo@openerp.com-20110928211326-0e51q7zlw4h2528z
2011-09-28 23:13:26 +02:00
Olivier Dony 209390d627 [MERGE] sync with latest trunk
bzr revid: odo@openerp.com-20110927165133-uwl7px6bxl6eu7us
2011-09-27 18:51:33 +02:00
Antony Lesuisse 7a88d9058d [MERGE] trunk
bzr revid: al@openerp.com-20110924145258-16r9qi7hr3dip1jz
2011-09-24 16:52:58 +02:00
Olivier Dony 0d3085d14f [MERGE] sync with latest trunk
bzr revid: odo@openerp.com-20110922154155-jq811w768d9zfgim
2011-09-22 17:41:55 +02:00
Olivier Dony 6e4a93cd22 [MERGE] sync w/ latest trunk
bzr revid: odo@openerp.com-20110921162128-22sp59cn4xv983q5
2011-09-21 18:21:28 +02:00
Xavier Morel 556a17d5bc [FIX] race condition in RegistryManager
When two requests arrive simultanously for the same uninitialized db,
the first request starts the db initialization, but the second one
immediately gets the partially uninitialized registry (actually just
created, so generally completely uninitialized), leading to an access
error in later code (as soon as a registry object is accessed).

Add a GRML (Global RegistryManager Lock) to ensure the RegistryManager
*never* returns a partially initialized registry.

The current implementation is simple (just lock all RegistryManager
methods before they manipulate registries), but overly broad. This is
an area which might be optimizable if there are perf/responsivity
issues (e.g. each Registry instance could have a lock, and the
RegistryManager would grab the instance's, allowing the inititlization
of registry A not to block registry B from being returned in heavily
concurrent uses).

However this is not an issue in multiprocessing scenarios, which are
being planned for the near future. So for now, being correct is
probably the best idea.

bzr revid: xmo@openerp.com-20110916075227-0zutzlxn2dcd94c4
2011-09-16 09:52:27 +02:00
Vo Minh Thu 79d0e39c4c [FIX] loading: load base only once.
bzr revid: vmt@openerp.com-20110902132712-j9bgfnzbmddarr7h
2011-09-02 15:27:12 +02:00
Vo Minh Thu b8a633e578 [MERGE] merged trunk.
bzr revid: vmt@openerp.com-20110831091325-t5gfm57tmkr0fbee
2011-08-31 11:13:25 +02:00