I agree that synchronization is not a good fix. It’s just a patch for my
purposes for now and I mention it mostly to better confirm the scope of the
problem. The binding class is
org.geotools.filter.v2_0.bindings.BBOXTypeBinding…
From: [email protected] [mailto:[email protected]] On Behalf Of Andrea
Aime
Sent: Monday, September 4, 2017 5:53 AM
To: Walter Stovall <[email protected]>; Niels Charlier <[email protected]>
Cc: [email protected]
Subject: Re: [Geoserver-devel] I'm a victim of GEOS-7961 NullPointer closed as
cannot-reproduce but I make it happen all the time
Hi Walter,
I believe the synchronization you're proposing is too wide and will cause
significant scalability degradation,
a more localized solution needs to be searched.
Which binding class are you referring to? The one in
org.geotools.filter.v2_0.bindings ?
(there are a few others, I believe this one would be used if you are doing WFS
2.0 requests only).
Regards
Andrea
On Sat, Sep 2, 2017 at 12:31 PM, Walter Stovall
<[email protected]<mailto:[email protected]>> wrote:
https://osgeo-org.atlassian.net/browse/GEOS-7961
This bug happens under load as a result of a multithreading bug in the
implementation of BBOXTypeBinding.getProperties. More specifically, the
partical.getContent() value there will be be corrupted/set to null by another
thread executing that same code. I’m not certain what the correct fix is yet
but I do have some good detail and can make it fail every time. I’m hoping
that somebody with more knowledge on the XSD classes might have some insight
that would help reach a solution.
I encounter this bug very reliably by running a jMeter ThreadGroup that sends
concurrent GetFeature requests that include a BBOX filter. I’ve since then
figured out how to repro the bug in eclipse and identified a fairly narrow
scope of code that is the root of the problem.
To repro this problem in eclipse place a breakpoint in
BBOXTypeBinding.getProperties at the following code:
particle.setContent(GML.getInstance().getSchema().resolveElementDeclaration(GML.Envelope.getLocalPart()));
particle.setMinOccurs(0);
Put the breakpoint on the particle.setMinOccurs call right after the above call
to setContent.
Now execute the GetFeature request and hit the breakpoint. Note that as
expected the particle.getContent() value at this point is not null, as it was
set by the proceeding line of code.
Now while sitting on that breakpoint execute another GetFeature and stop there
on the other thread. Again the value of particle.getContent() is not null.
But go to the original breakpoint in the first thread and see that
particle.getContent() IS NOW NULL!
In other words a GetFeature started on another thread has changed the
particle.getContent() of the original thread. NullPointer exceptions like that
shown in GEOS-7961 and others are now the result.
Digging deeper I see that each thread has a unique “particle” instance
(particle on one thread refers to a different object than particle on another
thread) – as expected since the object is obtained from the factory on entry to
getProperties. But in scenarios where this code works successfully (not forced
to fail as above) it’s at least interesting that the value of
particle.getContent() is the very same object instance on both threads.
Ultimately the root of the problem has to do with the EObjectImpl.eContainer
member – this is the object to which each particle refers.
While I don’t know what the best fix is, I do how to make this specific failure
never happen. I patched my code as follows by adding the thread
synchronization you see below in GetFeature…
synchronized(GetFeature.class) {
Encoder e = new Encoder(new FESConfiguration());
e.setOmitXMLDeclaration(true);
filter.append(e.encodeAsString(q.getFilter(), FES.Filter));
}
A more targeted fix would of course be much better and might address potential
failures other than GetFeature. I’m not sure what the right fix is but it
would appear to be centered on the behavior of the following, which is rather
convoluted for my brain to fully digest when considering changes.
if (content != null)
msgs = ((InternalEObject)content).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_PARTICLE__CONTENT, null, msgs);
if (newContent != null)
msgs = ((InternalEObject)newContent).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_PARTICLE__CONTENT, null, msgs);
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-devel mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/geoserver-devel
--
Regards,
Andrea Aime
==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V
for more information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i
file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo
è consentito esclusivamente al destinatario del messaggio, per le finalità
indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne
il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di
procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro
sistema. Conservare il messaggio stesso, divulgarlo anche in parte,
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse,
costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for the
attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act (Legislative
Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in
accord with its purpose, any disclosure, reproduction, copying, distribution,
or either dissemination, either whole or partial, is strictly forbidden except
previous formal approval of the named addressee(s). If you are not the intended
recipient, please contact immediately the sender by telephone, fax or e-mail
and delete the information in this message that has been received in error. The
sender does not give any warranty or accept liability as the content, accuracy
or completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of e-mail
transmission, viruses, etc.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel