Friday, 9 August 2013

Connections being intermittently left open on JBoss for requests from clients

Connections being intermittently left open on JBoss for requests from clients

The issue I'm having is that occasionally a connection for a clientside
request + the assosiated DB connection (using Oracle 10g RAC) get left
open on JBoss EAP 4.3.0 CP10. Also a JBM JMS queue dealing with messages
bound back to the server from and external service related to the request
gains messages that seem to stay in delivering state awfully long if not
infinitely (DeliveringCount keeps abnormally high).
So far no errors have been found anywhere to explain this, and the only
way to work around it is to restart JBoss when the connection pools are
starting to get full. The "hanging" of the request processing occurs quite
rarely, my estimate is that it happens for less than 0,01% of requests,
but curiously enough it only happens for certain kind of requests (getting
a live position for an object in the system).
It's a closed-source application but as I have understood things go
roughly like this:
the client sends a HTTP request to the server (via Apache proxy talking
AJP to the AS)
the server sends a request to a positioning service via JMS
the positioning service responds with the most recent data it has (should
happen within 1 sec)
the server responds to the client with the position data
There would seem to be some activity also with the object persistence DB
of the application although it really does not store the live position on
the object. Anyhow, no matter the reason for having also the DB connection
open during the request-response process, both the AJP connection and the
DB connection are left open without ever finalising the transaction. The
AJP connection is waiting for a lock from another AJP thread which has
already gone doing something else. Below is a sample stack trace extracted
with jconsole for a thread that is waiting eternally.
Name: ajp-0.0.0.0-8009-148
State: WAITING on
java.util.concurrent.locks.ReentrantLock$FairSync@285b829d owned by:
ajp-0.0.0.0-8009-100
Total blocked: 7 344 Total waited: 7 146
Stack trace:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:842)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1178)
java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:201)
java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
org.jboss.resource.adapter.jms.JmsManagedConnection.lock(JmsManagedConnection.java:393)
org.jboss.resource.adapter.jms.JmsXAResource.prepare(JmsXAResource.java:82)
org.jboss.resource.connectionmanager.xa.JcaXAResourceWrapper.prepare(JcaXAResourceWrapper.java:93)
com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord.topLevelPrepare(XAResourceRecord.java:271)
com.arjuna.ats.arjuna.coordinator.BasicAction.doPrepare(BasicAction.java:2880)
com.arjuna.ats.arjuna.coordinator.BasicAction.doPrepare(BasicAction.java:2837)
com.arjuna.ats.arjuna.coordinator.BasicAction.prepare(BasicAction.java:2389)
- locked
com.arjuna.ats.internal.jta.transaction.arjunacore.AtomicAction@6204cae5
com.arjuna.ats.arjuna.coordinator.BasicAction.End(BasicAction.java:1785)
- locked
com.arjuna.ats.internal.jta.transaction.arjunacore.AtomicAction@6204cae5
com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:88)
com.arjuna.ats.arjuna.AtomicAction.end(AtomicAction.java:216)
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commit(TransactionImple.java:240)
org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:501)
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:361)
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
org.jboss.ejb.Container.invoke(Container.java:960)
sun.reflect.GeneratedMethodAccessor149.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:112)
org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
$Proxy148.getPositions(Unknown Source)
<<<a call for the getPositions() method>>>
sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:402)
org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:309)
org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:333)
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:481)
org.apache.axis.server.AxisServer.invoke(AxisServer.java:323)
org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:854)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
com.osmoticweb.gzipfilter.GZIP2WayFilter.doFilter(GZIP2WayFilter.java:54)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:419)
org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:393)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1513)
java.lang.Thread.run(Thread.java:662)
I have waded through the JBoss issue tracker without finding a matching
case, and I have also spent literally days googling around for anything
like this but so far all has been in vain. Then again, this exceeds my
expertise on application servers and locking/transactions.
The hosting provider claims that there is no stateful component between
the hosts that would drop a connection it assumes dead. The AS is on a
virtualised Windows Server 2008 hosted in a VMWare ESX5i cluster, also the
proxy is hosted there. Oracle RAC (on "real" HW) is physically within the
same server room and within the same subnet.
I've inspected the network connections during a quiet time early in the
morning. Even though Tomcat status page on JBoss shows a number of long
living connections (which have very little traffic) which more or less
coincides with the number of open DB connections, looking at the output of
netstat -no on the JBoss server showed only one connection between Apache
and JBoss. The open DB connections did show in netstat output. Looking at
the netstat -no output on Apache server showed large number of connections
to JBoss in TIME_WAIT and plenty of client connections in FIN_WAIT2.
The fact that there is a thread waiting for a lock to be released by
another thread makes me wonder if there is a bug in JTA but at least it is
a rare bug and seems oddly to interfere with only transactions of one
kind. OTOH I'm not sure which way the TCP connections point at, and
communication with the staff of the application supplier hasn't so far
provided any solution. I've also experimented with timeout and keepalive
settings on both Apache and JBoss AJP connections without any change in
the situation. Also the fact that the open DB connections are toward the
object persistence DB (xa-datasource) and not toward the message
persistence DB (local-tx-datasource) is a bit confusing as there are those
messages in delivering state...
Any thoughts, pointers, ideas, or topics for further research?

Replacing a comma with Regex in C#

Replacing a comma with Regex in C#

I encountered a problem with quite simple thing I guess, I want to replace
each comma ',' in a string except for the ones that are surrounded by
digits. Examples:
hey, world -> hey,\nworld
hey , world -> hey,\nworld
they are simple, but now also:
hey,world -> hey,\nworld
hey),world -> hey),\nworld
(1,2) -> (1,2) << no change :P
I tried it with different Regexes and I can't really get it working as
easily as I'd like to. Matching the commas that I need is quite easy but
the problem is that I thought I can do it this way: Regex.Replace(input,
@"[^\d]\s*,\s*[^\d]", ",\n"); it works cool but it changes my:
hey,world into: he,\norld
I'd be glad if you could help me figure that out :)
Regards, Andrew

Thursday, 8 August 2013

Chrome extension doesn't work in Linux (works in windows)

Chrome extension doesn't work in Linux (works in windows)

Okay, this is weird.
This is my extension, and it works flawlessly in Windows (atleast on two
win7 machines), but when I tested it on linux (CentOS6 and Fedora18) it
failed to do anything when its icon was clicked (it should, at the very
least, display an alert). The options page still works, and saves data
properly.
After enabling developer mode in chrome://extensions/ you can click
_generated_background_page.html for the extension to see the JS console
for the addon.
That's where I saw the following error:
Error during tabs.executeScript: Cannot access contents of url
"https://www.google.com.au/". Extension manifest must request permission
to access this host.
Thing is, the windows machines showed no such error, shouldn't this be
platform independent?
The manifests are obviously the same, so how come the addon hasn't the
required permissions only on linux machines?
Mac is untested, if someone could try that for me, it might be useful



FURTHER INFORMATION
The error message above was given with the following information;
Located in the function chromeHidden.handleResponse on line 22 of the
script sendRequest

Libgdx New Api Move Instance Model along angle;

Libgdx New Api Move Instance Model along angle;

Okay, so with the new API for Libgdx available, I decided to jump into 3D.
All was well until I ran into what I thought was a basic problem.... So,
here it is.
The Idea is to move a Instance model that has been rotated along that
current angle/degree. Here is the code i intended on doing it with. Keep
in mind that this code has been died up and re-written quite a few times
so it aint perfect, I know.
if(isSentient && controllable){
if(walk){
if(Gdx.input.isKeyPressed(Keys.UP)){
pos = getPosition();
instance.transform.idt();
pos.z += Gdx.graphics.getDeltaTime() * Math.sin(rotation);
pos.x += Gdx.graphics.getDeltaTime() * Math.cos(rotation);
instance.transform.setToTranslation(pos);
}if(Gdx.input.isKeyPressed(Keys.DOWN)){
pos = getPosition();
instance.transform.idt();
pos.z -= Gdx.graphics.getDeltaTime() * Math.sin(1);
pos.x -= Gdx.graphics.getDeltaTime() * Math.cos(1);
instance.transform.setToTranslation(pos);
}if(Gdx.input.isKeyPressed(Keys.LEFT)){
rotation+=0.1;
pos = getPosition();
instance.transform.idt();
instance.transform.setToRotation(Vector3.Y,
rotation).trn(pos);
}if(Gdx.input.isKeyPressed(Keys.RIGHT)){
rotation-=0.1;
pos = getPosition();
instance.transform.idt();
instance.transform.setToRotation(Vector3.Y,rotation).trn(pos);
}
}
}

Guzzle in Ruby or Rails?

Guzzle in Ruby or Rails?

Guzzle is a PHP HTTP client framework with caching, plug-ins, logging,
etc. http://guzzlephp.org/
Is there an equivalent for Ruby or for Rails?

Does QVariant expect a null-terminated QByteArray?

Does QVariant expect a null-terminated QByteArray?

I need to construct a QVariant object from a QByteArray. Does the QVariant
constructor QVariant(const QByteArray & val) expect the raw bytes in the
QByteArray to be null-terminated?
Background info:
My QByteArray object was constructed with QByteArray::fromRawData(const
char * data, int size) and is not null-terminated.
My objective is to copy the raw bytes in my QByteArray object into a
database with QSqlQuery::bindValue() which expects a Qvariant object as
one of its arguments.
My guess is the the bytes in QByteArray must be null-terminated. I don't
see any other way how QVariant(const QByteArray & val) constructor could
be implemented.
Many thanks!

How do you use a button on an image that can be zoomed?

How do you use a button on an image that can be zoomed?

I have placed buttons at certain parts of an image. When the user touches
the button on the image the image will perform an animation. My problem is
I would like to give the user the ability to zoom the image. If the image
is zoomed in or out I need the button to change with the zoom so that it
is always covering the same part of the image. Any suggestions would be
greatly helpful. I am looking for a good place to start. Thanks for your
help.