Changes between Version 3 and Version 4 of TracDev/JournalingProposal
- Timestamp:
- Apr 17, 2008, 12:00:20 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/JournalingProposal
v3 v4 1 1 = Journaling Proposal = 2 2 3 See the full version in TracDev/Proposals/Journaling. 4 5 ---- 6 === In brief: === 7 ==== The Problem ==== 3 == The Problem == 8 4 Trac maintains coherency upon data changes by using various `I...Listener` 9 5 extension points. … … 11 7 While this works in many cases, this approach is somewhat flawed or insufficient in 12 8 situations where there are multiple server processes. And this is quite a common 13 scenario, with the widespread use of the Apache/prefork web front-end .9 scenario, with the widespread use of the Apache/prefork web front-end (see #5741). 14 10 15 ==== A solution ==== 11 Actually, the main problem comes from cached data. If what the listener does is only modify the database, then the other server process will see the updated data the next time they'll read it. But that won't work if they maintain an in-memory cache (like the !InterWiki component does for the InterMapTxt content, or the !WikiModule does for the list of wiki pages, etc.) 16 12 17 Every ''change'' event could be journalled. 18 A `journal` table could record all transactions and serve as 19 a basis for redispatching changes happening in one process 20 to other processes, in a generic way. 13 == A solution == 14 The solution is to invalidate those caches at the right time. 21 15 22 ''(and various other advantages)'' 16 - the !WikiModule does it by resetting the cache at regular intervals. This will work most of the time, but of course users will occasionally get the wrong content if the content of the cache lags too much behind the reality of the database 17 - with r6837, every change in !InterMapTxt will trigger a complete configuration reload. This will work, but it's a bit heavy handed. As the changes to that page are not supposed to be very frequent, I think that's an acceptable trade-off. 18 19 But a better solution would be to invalidate only the caches that need to be invalidated. 20 This could be achieved by using a table (`system`?) containing a key/value pair for every such cache. 21 22 The listener component that changes the cache will also store a new checksum value of the cached data it is responsible for, associated to a key specific to this cache. The corresponding components in other server processes will know that their cache is invalid by comparing their in-memory checksum with the checksum in the database (that'll be only one lookup, we can assume it will be cheap). If there's a mismatch, the cache is invalid an needs to be rebuild, like it would be from a listener change. 23 24 25 26 See also TracDev/Proposals/Journaling (which is somewhat older and more heavy weight)