Still problems with map locks

23 views
Skip to first unread message

Kevin C. Dorff

unread,
Oct 31, 2009, 9:38:08 PM10/31/09
to haze...@googlegroups.com
I tried the latest Hazelcast snapshot (downloaded the night of
10/31/2009). Using the following groovy code:


------------- START counter.groovy -------------

import com.hazelcast.core.*

Runtime.getRuntime().addShutdownHook(new ShutdownHook())

IMap<String, Integer> map = Hazelcast.getMap("cache");
ILock lock = Hazelcast.getLock(map)

int count
while(true) {
print "[l]"
lock.lock()
try {
count = map.get("counter") ?: 0
map.put("counter", count + 1)
} finally {
lock.unlock()
print "[u]"
}
println count
Thread.sleep(2000)
}

private class ShutdownHook extends Thread {
public void run() {
Hazelcast.shutdown()
}
}

------------- END counter.groovy -------------

One program runs fine but when started on additional nodes I get
serialization exceptions

java.lang.NullPointerException
at com.hazelcast.impl.FactoryImpl$MProxyImpl.setFactory(FactoryImpl.java:1649)
at com.hazelcast.impl.FactoryImpl$FactoryAwareNamedProxy.readData(FactoryImpl.java:2254)
at com.hazelcast.nio.SerializationHelper.readObject(SerializationHelper.java:84)
at com.hazelcast.impl.FactoryImpl$ProxyKey.readData(FactoryImpl.java:645)
at com.hazelcast.nio.Serializer$DataSerializer.read(Serializer.java:202)
at com.hazelcast.nio.Serializer$DataSerializer.read(Serializer.java:193)
at com.hazelcast.nio.Serializer.readObject(Serializer.java:96)
at com.hazelcast.impl.ThreadContext.toObject(ThreadContext.java:137)
at com.hazelcast.nio.IOUtil.toObject(IOUtil.java:62)
at com.hazelcast.impl.BaseManager$KeyValue.getKey(BaseManager.java:293)
at com.hazelcast.impl.ConcurrentMapManager$Entries$EntryIterator.next(ConcurrentMapManager.java:2093)
at com.hazelcast.impl.FactoryImpl.<init>(FactoryImpl.java:206)
at com.hazelcast.impl.FactoryImpl.newFactory(FactoryImpl.java:95)
at com.hazelcast.core.Hazelcast.getDefaultInstance(Hazelcast.java:48)
at com.hazelcast.core.Hazelcast.getMap(Hazelcast.java:72)
at com.hazelcast.core.Hazelcast$getMap.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at counter.run(counter.groovy:5)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:256)
at groovy.lang.GroovyShell.run(GroovyShell.java:218)
at groovy.lang.GroovyShell.run(GroovyShell.java:147)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:493)
at groovy.ui.GroovyMain.run(GroovyMain.java:308)
at groovy.ui.GroovyMain.process(GroovyMain.java:294)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:111)
at groovy.ui.GroovyMain.main(GroovyMain.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
java.io.IOException: Problem reading DataSerializable class :
com.hazelcast.impl.FactoryImpl$ProxyKey, exception:
java.lang.NullPointerException
at com.hazelcast.nio.Serializer$DataSerializer.read(Serializer.java:206)
at com.hazelcast.nio.Serializer$DataSerializer.read(Serializer.java:193)
at com.hazelcast.nio.Serializer.readObject(Serializer.java:96)
at com.hazelcast.impl.ThreadContext.toObject(ThreadContext.java:137)
at com.hazelcast.nio.IOUtil.toObject(IOUtil.java:62)
at com.hazelcast.impl.BaseManager$KeyValue.getKey(BaseManager.java:293)
at com.hazelcast.impl.ConcurrentMapManager$Entries$EntryIterator.next(ConcurrentMapManager.java:2093)
at com.hazelcast.impl.FactoryImpl.<init>(FactoryImpl.java:206)
at com.hazelcast.impl.FactoryImpl.newFactory(FactoryImpl.java:95)
at com.hazelcast.core.Hazelcast.getDefaultInstance(Hazelcast.java:48)
at com.hazelcast.core.Hazelcast.getMap(Hazelcast.java:72)
at com.hazelcast.core.Hazelcast$getMap.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at counter.run(counter.groovy:5)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:256)
at groovy.lang.GroovyShell.run(GroovyShell.java:218)
at groovy.lang.GroovyShell.run(GroovyShell.java:147)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:493)
at groovy.ui.GroovyMain.run(GroovyMain.java:308)
at groovy.ui.GroovyMain.process(GroovyMain.java:294)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:111)
at groovy.ui.GroovyMain.main(GroovyMain.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
Caught: java.lang.RuntimeException: java.io.IOException: Problem
reading DataSerializable class :
com.hazelcast.impl.FactoryImpl$ProxyKey, exception:
java.lang.NullPointerException
at counter.run(counter.groovy:5)

I was hoping 1.8 snapshot would work. 1.7 works on N nodes until you
stop a node at which point the lock stops being available to the other
running nodes, in most cases. New nodes added in can never obtain the
lock, it seems.

This code should be pretty trivial and supported, no? Am I doing
something odlly wrong?

Kevin

Talip Ozturk

unread,
Nov 2, 2009, 5:43:58 PM11/2/09
to haze...@googlegroups.com
Kevin,

This is not related to locks at all. Locks are fine but serialization
of the map proxy (you are using a map instance as the lock object) is
broken.
Created an issue for this:
http://code.google.com/p/hazelcast/issues/detail?id=157

Now it is actually fixed. Please download and try the latest snapshot.

It is now fixed in a way that all map/queue/etc. proxies are
serializable in any case + you can even serialize HazelcastInstance!

Written test cases for this issue is also part of Hazelcast cluster
test suite now so that it doesn't get broken again later.

Thanks for finding out.
-talip
Reply all
Reply to author
Forward
0 new messages