[jsword-devel] [JIRA] Commented: (JS-109) Modules are not read in a thread safe way
Chris Burrell (JIRA)
jira at crosswire.org
Mon Nov 29 06:13:11 MST 2010
[ http://www.crosswire.org/bugs/browse/JS-109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13574#action_13574 ]
Chris Burrell commented on JS-109:
----------------------------------
Indeed, in fact the problem would happen for any application that does two concurrent calls. The first time I saw this was with a single user having the page/screen load up a passage on a left pane and a passage on the right pane. If the passage is from the same Book, then you hit the issue.
I'd rather avoid synchronisation at the higher level, since that would basically mean that no two users (or the same user) would be able to use the same book at any one time. Given some books are used much more frequently than others (e.g. ESV, KJV, StrongGreek for every click on a word) , I can see bottlenecks appearing. Happy to have a look at some point, but it won't be this week, and unlikely to be the week after
Would it make sense to push the internal cache up a level? Then perhaps putting the syncrhonised around the existing implementation might be worth consideration.
1- check cache
2a- if yes, retrieve and return
2b- if no, do the read and synchronise (maybe use double checked locking pattern to ensure read only happens once)
We can hopefully assume the cache is thread-safe. It's unlikely content in the cache will be changed at any point. And if for some reason the underlying implementation did, I'd be happy to have to restart the server (for now). It could be responsibility of the programmer to trigger a cache retry if modules are updated.
Not sure how easy that is though. EHCache is a good cache. Not sure if it meets the criteria that JSword requires to be portable...
> Modules are not read in a thread safe way
> -----------------------------------------
>
> Key: JS-109
> URL: http://www.crosswire.org/bugs/browse/JS-109
> Project: JSword
> Issue Type: Bug
> Components: o.c.jsword.passage
> Affects Versions: 1.6.1
> Reporter: Chris Burrell
> Assignee: DM Smith
>
> I believe the problem is because ZVerseBackend is not thread-safe. Being a singleton, it starts sharing all its arrays declared as member variables. As a result, when two passages from the same "Book" (for e.g. KJV) are used, there is corruption, since the data read for Thread A might also be shared by Thread B!
> A few solutions I can think of:
> - do they need to be singletons? I guess it makes sense, but what is the cost involved in them being singletons? Don't know the code base well enough yet.
> - do the member variables need to member variables, or can be make them local variables? Do they share state across methods?
> - If the option above doesn't work, then synchronising the method might be worth looking at, however, in a web environment, that would potentially cause serious bottlenecks, especially if there is a default version (and default passage) that is displayed when the user brings the page up.
> Any thoughts?
> Chris
> On 7 November 2010 00:04, Chris Burrell <chris at burrell.me.uk> wrote:
> On this last note, I believe we have concurrency issues. I have a two column page, displaying one passage each. On load of the page they load up a passage each, but then this once, the passage on the right (only verse 1) has gone to the left (which was requesting just one verse but from a different passage:
> left pane: requested Acts 2:10, got Romans 1:1
> right pane: corrupt XML in verse 1, verse 2 seems to be Romans 1:2-following
> Anyone else come across those issues?
> Chris
> On 6 November 2010 20:53, Chris Burrell <chris at burrell.me.uk> wrote:
> Another question too. It seems sometimes, both in bible desktop and my current application, the html rendered is broken?
> Any ideas why that might be?
> For example, I get:
> "<div class="passageText ui-widget"><div><h2 class="heading">Acts 2:10</h2><span class="verse"><span class="w"><sup class="verseNumber">10</sup></span><span class="w"><span class="text">emma="strong:G1909" morph="robinson:PREP" src="4">upon every soul of man that doeth evil, of the Jew first, and also of the Gentile;</span></span></span> </div></div>"
> The above in bold shows that it didn't get XSLTed properly.
> Instead of "<div class="passageText ui-widget"><div><h2 class="heading">Acts 2:10</h2><span class="verse"><sup class="verseNumber">10</sup><span class="w"><span class="text"> </span> </span><span class="w"><span class="text"> </span> </span><span class="w"><span class="text">Phrygia</span></span>, <span class="w"><span class="text"> </span> </span><span class="w"><span class="text">and</span></span> <span class="w"><span class="text">Pamphylia</span></span>, <span class="w"><span class="text">in Egypt</span></span>, <span class="w"><span class="text">and</span></span> <span class="w"><span class="text">in the parts</span></span> <span class="w"><span class="text">of Libya</span></span> <span class="w"><span class="text">about</span></span> <span class="w"><span class="text">Cyrene</span></span>, <span class="w"><span class="text">and</span></span> <span class="w"><span class="text">strangers</span></span> <span class="w"><span class="text">of Rome</span></span>, <span class="w"><span class="text">Jews</span></span> <span class="w"><span class="text"> </span> </span><span class="w"><span class="text">and</span></span> <span class="w"><span class="text">proselytes</span></span>,</span> </div></div>"
> So somehow it lost a whole load on the way out of the XSLT? The only difference is that the first one is on startup of the server, the second is with a refresh in the browser. Perhaps something hasn't loaded up correctly/entirely?
> Chris
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://www.crosswire.org/bugs/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jsword-devel
mailing list