Commit Graph

27 Commits

Author SHA1 Message Date
Fabio Erculiani
363c6a175f [entropy.*] migrate all retrieveNeeded uses to retrieveNeededLibraries 2014-10-20 15:04:19 +02:00
Fabio Erculiani
7b2810c054 [entropy.db] rewrite needed libraries SQL schema, keep compat. 2014-09-30 09:10:11 +01:00
Fabio Erculiani
1f2575204e [entropy.locks] make ResourceLock reentrant wrt to individual threads only 2013-12-26 22:52:11 +01:00
Fabio Erculiani
aa4e2441be [entropy.client] move _enabled_repos to a property, allow lazy loading 2013-12-12 18:35:17 +01:00
Fabio Erculiani
3a7269aa5c [entropy.db] EntropyBaseRepository: turn lock methods into no-op if direct mode
Now that the repository lock is reentrant, it's good to have the
methods take into account direct mode as well. In direct mode,
we explicitly don't want to deal with any kind of locking, because
we accept to manipulate stale data. In order to hide locking code
from the outside and have it transparently managed inside entropy.*
methods, we must respect requests made in direct mode.
2013-12-12 14:25:44 +01:00
Fabio Erculiani
023e8e1b72 [entropy.db] EntropyBaseRepository: make possible to permanently enable direct mode 2013-12-12 10:21:27 +01:00
Fabio Erculiani
7808ad6b92 [entropy.db.sqlite] migrate locking code to entropy.locks.ResourceLock
The new EntropySQLiteRepository uses ResourceLock, and gains support
for reentrancy, anti-deadlock safety measures (only for nested calls),
unification of memory and file repositories locking code (the semantics
was already the same).
2013-12-10 21:42:34 +01:00
Fabio Erculiani
94ab49fd0b [tests] use const_mk{s,d}temp instead of tmpfile ones, default TMPDIR to /var/tmp 2013-12-09 14:36:34 +01:00
Fabio Erculiani
3545f2b619 [entropy.db] add direct access support to repository
In latency sensitive code paths, the performance penality caused
by file lock contention and memory cache invalidation is too high.
This problem happens in Rigo, which is extremely latency sensitive.
Since we don't want to crap on the user, a way to solve this is
letting API consumers skip the memory cache and read data directly
from the database store. The trade off is that data may be stale,
incomplete, or invalid, but as long as the consumer is aware of this,
that's fine.
2013-12-07 20:30:06 +01:00
Fabio Erculiani
c54c893e55 [entropy.db] implement locking infrastructure (with the same semantics) for in-memory repositories 2013-12-07 20:27:57 +01:00
Fabio Erculiani
d7f22534b2 [entropy.db] rewrite locking infrastructure, handle multithreading use case 2013-12-07 20:27:57 +01:00
Fabio Erculiani
e717f7a1b3 [entropy.db.sqlite] drop support for locking based on rwsem for memory repositories
Firstly, rwsem is semantically different from flock (but this was known) and
this may confuse the API consumer. Secondly, the locking infrastructure is
purely meant for inter-process synchronization, threads synchronization is
not a current use case.
2013-12-07 20:25:55 +01:00
Fabio Erculiani
366fc37f59 [entropy.db.sqlite] implement locking infrastructure 2013-12-07 20:24:23 +01:00
Fabio Erculiani
464ae46d90 [tests] drop debug output 2013-11-29 19:29:12 +01:00
Fabio Erculiani
e406a4edaa [entropy.*] create new dependencies metadata "pkg_dependencies"
The old "dependencies" metadata is deprecated. It was found that
the generated metadata might get corrupted by colliding atom strings.
The new implementation avoids collisions completely and is more
efficient.
2013-11-29 19:15:44 +01:00
Fabio Erculiani
e7c482ac21 [entropy.db] add atom field to preserved_libs metadata 2013-11-27 12:30:09 +01:00
Fabio Erculiani
96ef5868f4 [entropy.db] initial repository database support for preserved libraries 2013-11-20 17:09:48 +01:00
Fabio Erculiani
4183fe9b6c [tests] db: fix some tests to accomodate Python 3.3 2013-04-02 23:23:42 +01:00
Fabio Erculiani
b395b13d84 [tests] db: fix test_libs_download 2013-03-23 11:42:42 +00:00
Fabio Erculiani
7473ff1c04 [tests] db: extend test_needed with another test pkg 2012-12-22 12:46:53 +01:00
Fabio Erculiani
0deb4464e7 [entropy.const] kill etpUi['mute'] 2012-11-06 21:16:16 +01:00
Fabio Erculiani
2512df68ad [lib/] drop etpUi['debug'] 2012-11-06 20:13:49 +01:00
Fabio Erculiani
1b10177640 [entropy.db.sql] major cursor and connection pooling rework
The original idea was to avoid doing cursor and connection resources
cleanup (left by old and dead threads) synchronously every time
_connection() and/or _cursor() is accessed. This strategy also had
a huge drawback: with no activity on the object, resources were
left hanging there forever.

This commit introduces a better strategy for transparent and automatic
cleanup of resources belonging to terminated threads: every time a new
thread_id arrives at _cursor() or _connection(), a new daemon thread
starts and synchronizes with the caller through a simple Thread.join()
(because it's a daemon thread, we can join() daemon threads as well,
even if this is not really compliant with the specs, but it seems to work
just fine in Python).
When the caller thread is joined, it is possible to start the resources
cleanup procedure, carefully taking into account that thread_ids are
recycled and thus there might be clashing with newly created threads.

This helped a design issue to emerge from the sand (like a zombie
at the seaside): it is impossible to cleanup resources left by the
MainThread because this thread never ends living, and if it dies,
everything dies, obviously. So, the first implementation of this new
strategy was NOT touching the MainThread resources but then, the old
behaviour was to kill them as well on EntropyRepository.close().
So, the final version of this patch kept the old buggy behaviour of
touching MainThread stuff (nein, nein, nein, nein would Hitler say).
However, a new keyword argument "safe" has been added to the close()
method so it is possible to start migrating code to the dark side of the
power.

This means nothing really changed for API consumers yet, just entropy.db.sql
code being more efficient (no weird for loops and synchronous crap)
and actually faster (multi-threading ftw).
2012-08-15 20:59:45 +02:00
Fabio Erculiani
27a51598a0 [entropy.db] move most of the standard SQL code to entropy.db.sql 2012-08-11 21:58:41 +02:00
Fabio Erculiani
90400c4ade [tests/db] drop SCHEMA_2010 related code 2012-08-10 14:05:05 +02:00
Fabio Erculiani
b8976f4c0c [entropy.db] EntropyRepository: expose connection and cursor pools
This commit makes possible for subclasses to reimplement the
connection and cursor pool logic.
2012-07-07 13:29:29 +02:00
Fabio Erculiani
69a0bb87e0 [entropy] move libraries/ to lib/ 2011-10-17 14:27:58 +02:00