Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account
List archives

Do implementations of Watcher need to be thread-safe?

Adding observers
(17 lines)
node symlinks
(15 lines)
Jul 21, 2010
Joshua Ball
Joshua Ball
Hi,

Do implementations of Watcher need to be thread-safe, or can I assume
that process(...) will always be called by the same thread?

Thanks,
Josh "Ua" Ball


Reply
Tags: balljoshthread
Messages in this thread
Do implementations of Watcher need to be thread-safe?
Similar Threads
Created: (SLING-1545) ScripteEngineManagerFactory is not thread safe
ScripteEngineManagerFactory is not thread safe

PATCH/puppet 2/4] Fix #4244 - Cached Attributes is not thread safe
The underlying hash is not protected and thus two threads accessing
the cached value at the same time and one expiring the value can result
in a race condition.

This patch synchronizes the access to the value_cache underlying hash.

Signed-off-by: Brice Figureau <brice-pupp### @daysofwonder.com>
---
 lib/puppet/util/cacher.rb |   31 +++++++++++++++++++++
Re: [PATCH/puppet 2/4] Fix #4244 - Cached Attributes is not thread safe
The second definition of cached_value will just overwrite the first,
meaning that this won't work as written.  However, renaming the two
argument form "set_cache_value" or some such (or just inlineing it)
should resolve this.

Other than that, +1, and I can sort the details out when I merge.

On Sun, Jul 25, 2010 at 10:24 AM, Brice Figureau
<brice-pupp### @daysofwonder.com> wrote:
 The underlying hash is not protected and thus two threads accessing
 the cached value at the same time and one expiring the value can
result
 in a race condition.

 This patch synchronizes the access to the value_cache underlying
hash.

 Signed-off-by: Brice Figureau <brice-pup### @daysofwonder.com>
 ---
  lib/puppet/util/cacher.rb |   31 +++++++++++++++++++++
PATCH/puppet 1/1] Minimal fix for #4243 -- import isn't thread safe
The import function was calling type_loader#import directly so that it
could
pass in the current file name, but by doing so it was thwarting the
thread-
safety locking level.  This patch rearanges things so that all imports go
through the same (thread safe) code path while retaining the current_file
passing, error handling, etc. from the old structure.

Signed-off-by: Markus Roberts <Mar### @reality.com>
---
 lib/puppet/parser/parser_support.rb  |    2 +-
 lib/puppet/parser/type_loader.rb     |   28 +++++++++++++
Re: [PATCH/puppet 2/4] Fix #4244 - Cached Attributes is not thread safe
On 25/07/10 21:03, Markus Roberts wrote:
 The second definition of cached_value will just overwrite the first,
 meaning that this won't work as written.  However, renaming the two
 argument form "set_cache_value" or some such (or just inlineing it)
 should resolve this.

Really? I thought ruby would dispatch to the correct method.
/me doing too much java at day job :)

The irony of this is that I initially named the method set_cache_value,
and it felt so java that I changed it :)

 Other than that, +1, and I can sort the details out when I merge.

OK, thanks.






Regarding the process method of Watcher Interface
Hi,

I have a class (X) that implements the Watcher Interface. Consider, an
instance of 'X' is registered as a callback object for different Znode
changes. Now, If there are several simultaneous changes that happen on
these
registered znodes, then will these events be fired by the zookeeper to
callback object sequentially or should I have to synchronize the process()
method of Watcher interface in order to handle these events sequentially?
Suppose, I have synchronized the process method(), then will the events
fired by zookeeper be missed by the callback object when some other event
is
being processed? Or, does the zookeeper ensures that all the events are
finally reached and handled by the callback object?

Thanks & Regards,
Srikanth.


How people write web service implementations
Hi,

    What is the popular way to write JAX-WS SOA web services? Use
wsdl2java
and use the default JAXB binding or any other way? I have seen the JAX-WS
Provider mechanism but couldn't find much resources on how to deploy such
a
service. From this I guess it is not popular with CXF community.

Regards,
Anto


Created: (PIG-1516) finalize in bag implementations causes pig to run out of memory in reduce
finalize in bag implementations causes pig to run out of memory in reduce 

DO NOT REPLY New: Wrong memory leak detection: executor thread reported as web app thread
https://issues.apache.org/bugzilla/show_bug.cgi?id=49414

           Summary: Wrong memory leak detection: executor thread reported
                    as web app thread
           Product: Tomcat 7
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: de### @tomcat.apache.org
        ReportedBy: mguill### @yahoo.fr


Created an attachment (id=25566)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25566)
Unit test allowing to generate the wrong log message (but doesn't catpure
the
log to really test it)

At Tomcat shutdown I have quite often following message

SEVERE: The web application [/] appears to have started a thread named
[http-8001-exec-1] but has failed to stop it. This is very likely to
create a
memory leak. 

Looking into the details it appears that a request is still being
processed.
The thread that is detected as leak is not a user thread but Tomcat's
executor
thread.

I'm not sure what would be the right behaviour here: complain about a
request
that is still being processed or to wait for it. In any case, Tomcat
shouldn't
complain with current message as it is too misleading and leads to
ignoring
real memory leak messages.

The root cause of the problem is the strategy used to detect threads
started by
a web app which isn't able to correctly identify threads started by Tomcat
itself (contextClassLoader is changed at each request). A solution could
be to
use a ThreadGroup to identify "Tomcat threads". If you see this as a good
solution, I can try to prepare a patch.

Same problem occurs in Tomcat 6.




Created: (DERBY-4711) Hung thread after another thread is interrupted
Hung thread after another thread is interrupted

Hung thread after another thread is interrupted
Hi all,

We've seen a problem today where we have several threads querying our
database and when one gets interrupted the others are stuck waiting for a
lock. Here is the stack trace for the stuck thread(s):

daemon prio=4
"DefaultExecutorService-pool-1-thread-47" Id=98 WAITING on
org.apache.derby.impl.se### @6e6f45a1
at java.lang.Object.wait(Native Method)
 -  waiting on org.apache.derby.impl.s### @6e6f45a1
at java.lang.Object.wait(Object.java:485)
 at
org.apache.derby.impl.services.locks.ActiveLock.waitForGrant(ActiveLock.java:115)
at
org.apache.derby.impl.services.locks.ConcurrentLockSet.lockObject(ConcurrentLockSet.java:463)
 at
org.apache.derby.impl.services.locks.ConcurrentLockSet.zeroDurationLockObject(ConcurrentLockSet.java:855)
at
org.apache.derby.impl.services.locks.AbstractPool.zeroDurationlockObject(AbstractPool.java:297)
 at
org.apache.derby.impl.services.locks.ConcurrentPool.zeroDurationlockObject(ConcurrentPool.java:28)
at
org.apache.derby.impl.store.raw.xact.RowLocking2nohold.lockRecordForRead(RowLocking2nohold.java:89)
 at
org.apache.derby.impl.store.access.heap.HeapController.lockRow(HeapController.java:520)
at
org.apache.derby.impl.store.access.heap.HeapController.lockRow(HeapController.java:638)
 at
org.apache.derby.impl.store.access.btree.index.B2IRowLocking3.lockRowOnPage(B2IRowLocking3.java:309)
at
org.apache.derby.impl.store.access.btree.index.B2IRowLocking3._lockScanRow(B2IRowLocking3.java:599)
 at
org.apache.derby.impl.store.access.btree.index.B2IRowLockingRR.lockScanRow(B2IRowLockingRR.java:105)
at
org.apache.derby.impl.store.access.btree.BTreeForwardScan.fetchRows(BTreeForwardScan.java:305)
 at
org.apache.derby.impl.store.access.btree.BTreeScan.fetchNextGroup(BTreeScan.java:1585)
at
org.apache.derby.impl.sql.execute.BulkTableScanResultSet.reloadArray(BulkTableScanResultSet.java:327)
 at
org.apache.derby.impl.sql.execute.BulkTableScanResultSet.getNextRowCore(BulkTableScanResultSet.java:282)
at
org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(BasicNoPutResultSetImpl.java:460)
 at
org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:427)
-  locked org.apache.derby.impl.### @445d374b
 at
org.apache.derby.impl.jdbc.EmbedResultSet.next(EmbedResultSet.java:371)
        ...

So is using Thread.interrupt() the correct way to interrupt a long running
query? Currently our worker threads are using
'java.util.concurrent.ThreadPoolExecutor' to run our queries and it calls
'interrupt()' when it shuts down.

This was with Derby 10.5.3.0 and JRE 1.6.0_19-b04 on Windows Server 2008.


Thanks in advance,


Luke Quinane


Re: Safe way to backup an RDB file
Can an AOF file be backed up with a simple 'cp' command? Or must we
create a dump file to do a backup?

Thanks,
David

On Jul 27, 3:39 pm, Salvatore Sanfilippo <ant### @gmail.com> wrote:
 On Tue, Jul 27, 2010 at 9:31 AM, teleo <lev.### @gmail.com>
wrote:
 > What is the safest way to backup an RDB file in Redis?

 In Redis .rdb files can be copied while the server is running without
 any need of lock. No corruption is possible since the new file is
 always saved in a temp location and atomically rename(2)d to the new
 location.

 So just use "cp" :)

 Cheers,
 Salvatore

 > Thanks,
 > T

 > --
 > 
Re: Is it safe to replace master.db file?
OK thanks for the reply.  I have a partition and all my entries are under
that partition.  What I replaced was the master.db from in system folder
not
in my partition folder so will it affect?




Is it safe to replace master.db file?
Hi,

I am using ApacheDs 1.5.4, after running successfully for a long time, now
getting the following error:

Exception in thread "main" java.lang.NullPointerException
        at
org.apache.directory.server.core.entry.ClonedServerEntry.<init>
        (ClonedServerEntry.java:67)
        at

org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition.lookup
(JdbmPartition.java:457)
        at

org.apache.directory.server.core.partition.impl.btree.ServerEntryCursorAdaptor.get
(ServerEntryCursorAdaptor.java:140)
        at

org.apache.directory.server.core.partition.impl.btree.ServerEntryCursorAdaptor.get
(ServerEntryCursorAdaptor.java:40)
        at

org.apache.directory.server.core.filtering.BaseEntryFilteringCursor.next
(BaseEntryFilteringCursor.java:502)
        at org.apache.directory.server.core.authz.GroupCache.initialize
        (GroupCache.java:151)
        at org.apache.directory.server.core.authz.GroupCache.<init>
        (GroupCache.java:115)
        at

org.apache.directory.server.core.authz.AciAuthorizationInterceptor.init
(AciAuthorizationInterceptor.java:211)
        at

org.apache.directory.server.core.interceptor.InterceptorChain.register0
(InterceptorChain.java:439)
        at

org.apache.directory.server.core.interceptor.InterceptorChain.register
(InterceptorChain.java:395)
        at
        org.apache.directory.server.core.interceptor.InterceptorChain.init
        (InterceptorChain.java:255)
        at
       
org.apache.directory.server.core.DefaultDirectoryService.initialize
        (DefaultDirectoryService.java:1385)
        at
org.apache.directory.server.core.DefaultDirectoryService.startup
        (DefaultDirectoryService.java:840)
        at org.apache.directory.server.configuration.ApacheDS.startup
        (ApacheDS.java:126)
        at org.apache.directory.server.Service.init(Service.java:86)
        at org.apache.directory.server.UberjarMain.main
        (UberjarMain.java:56)



DO NOT REPLY SSI Servlet should support safe configuration
https://issues.apache.org/bugzilla/show_bug.cgi?id=48960

--- Comment #8 from Mark Thomas <mar### @apache.org> 2010-07-13
17:16:40 EDT ---
The diff is inverted and the patch is using tabs rather than spaces. I
should
eb able to work with that but you might need to fix it.




DO NOT REPLY SSI Servlet should support safe configuration
https://issues.apache.org/bugzilla/show_bug.cgi?id=48960

--- Comment #9 from Mark Thomas <mar### @apache.org> 2010-07-13
17:38:55 EDT ---
In the end I used the patch a guide and write a new one. Some additional
comments:
- if you do an svn diff against a normal source tree patches usually apply
cleanly
- new features should be documented

The patch has been applied to truck and proposed for 6.0.x