<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Damir
<div class=""><br class="">
</div>
<div class="">Thanks for reporting having an issue with query.</div>
<div class=""><br class="">
</div>
<div class="">Inorder to load orphaned images your query should be:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">sql = """select img from Image img</div>
<div class="">    join fetch img.fileset as fs </div>
<div class="">    join fetch fs.usedFiles as uf</div>
<div class="">    join fetch uf.originalFile as of</div>
<div class="">    join fetch img.pixels as pxl</div>
<div class="">    join fetch pxl.pixelsType as pxt</div>
<div class="">    where </div>
<div class="">        not exists (</div>
<div class="">            select obl from DatasetImageLink as obl </div>
<div class="">            where obl.child=img.id) </div>
<div class="">        and not exists (</div>
<div class="">            select ws from WellSample as ws where ws.image=img.id )</div>
<div class="">    order by lower(img.name), img.id</div>
<div class="">“""</div>
<div class=""><br class="">
</div>
<div class="">You have to check if DatasetImageLink exist rather then dataset id is null</div>
<div class="">Please remember that image can be in Plate.</div>
<div class=""><br class="">
</div>
<div class="">Let us know if that works better</div>
<div class="">
<div apple-content-edited="true" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br class="Apple-interchange-newline">
Ola</div>
<div apple-content-edited="true" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
Software Engineer</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
Open Microscopy Environment</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
University of Dundee</div>
</div>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 12 Feb 2016, at 19:56, Damir Sudar <<a href="mailto:dsudar@lbl.gov" class="">dsudar@lbl.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hi all,
<div class=""><br class="">
</div>
<div class="">We're using the API to query the OMERO server (currently running 5.1.4) and have run into a situation where this can crash the server or at least get the server into a state where it becomes unresponsive. A hopefully useful chunk from the OMEROweb.log
 is enclosed. I did not see anything in the other logs that appeared related to the activity that caused the crash or the crash itself. An excerpt of the code that causes the crash is here:</div>
<div class=""><br class="">
</div>
<div class="">
<div style="font-family:Calibri;font-size:16px" class="">const std::string orphanedImagesQueryString =</div>
<div style="font-family:Calibri;font-size:16px" class="">    "select img from Image as img "</div>
<div style="font-family:Calibri;font-size:16px" class="">    "left outer join fetch img.datasetLinks as idl "</div>
<div style="font-family:Calibri;font-size:16px" class="">    "left outer join fetch idl.parent as dst "</div>
<div style="font-family:Calibri;font-size:16px" class="">    "left outer join fetch img.fileset as fs "</div>
<div style="font-family:Calibri;font-size:16px" class="">    "join fetch fs.usedFiles as uf "</div>
<div style="font-family:Calibri;font-size:16px" class="">    "join fetch uf.originalFile as of "</div>
<div style="font-family:Calibri;font-size:16px" class="">    "join fetch img.pixels as pxl "</div>
<div style="font-family:Calibri;font-size:16px" class="">    "join fetch pxl.pixelsType as pxt ";</div>
<div style="font-family:Calibri;font-size:16px" class="">//  "where <a href="http://dst.id/" target="_blank" class="">dst.id</a> is null";</div>
<div style="font-family:Calibri;font-size:16px" class=""><br class="">
</div>
<div style="font-family:Calibri;font-size:16px" class=""><span style="font-size:12pt" class="">omero::sys::ParametersIPtr dsParams = new omero::sys::ParametersI();</span></div>
<div style="font-family:Calibri;font-size:16px" class="">dsParams->addLong("id", omero::rtypes::rlong(803));</div>
<div style="font-family:Calibri;font-size:16px" class="">auto imageObjects = query->findAllByQuery(orphanedImagesQueryString, dsParams);</div>
<div style="font-family:Calibri;font-size:16px" class="">for (auto image : omero::cast<omero::model::ImagePtr>(imageObjects)) {</div>
<div style="font-family:Calibri;font-size:16px" class="">    std::cout << "i: "  << image->getId()->getValue() << " " << image->getName()->getValue() << "\n";</div>
<div style="font-family:Calibri;font-size:16px" class="">}</div>
<div style="font-family:Calibri;font-size:16px" class=""><br class="">
</div>
<div style="font-family:Calibri;font-size:16px" class="">I'm not sure, but as I understand, the crash occured when I commented "where <a href="http://dst.id/" target="_blank" class="">dst.id</a> is null" condition. The query with "where <a href="http://dst.id/" target="_blank" class="">dst.id</a> is
 null" didn't return result and I tried to remove the  "is null" condition - to see what would happen. And the server crashed.</div>
</div>
<div style="font-family:Calibri;font-size:16px" class=""><br class="">
</div>
<div style="font-size:13px" class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div style="word-wrap:break-word" class="">It appears that the server crashed when we tried to query images without parent dataset ("orphaned images”). I.e. something related to handling a situation where a parent pointer is NULL.</div>
<div style="word-wrap:break-word" class=""><br class="">
</div>
</div>
</div>
</div>
<div style="font-size:13px" class="">- Damir</div>
<div class="">
<div class=""><br class="">
</div>
-- <br class="">
<div class="gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">Damir Sudar - Staff Scientist<br class="">
Lawrence Berkeley National Laboratory<br class="">
One Cyclotron Road, MS 977, Berkeley, CA 94720, USA<br class="">
T: 510/486-5346 - F: 510/486-5586 - E: <a href="mailto:DSudar@lbl.gov" target="_blank" class="">
DSudar@lbl.gov</a><br class="">
<br class="">
</div>
</div>
<div class="">Visiting Scientist, Oregon Health and Science University</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<span id="cid:B0D69C42-B3BC-47E6-A8BF-0908F0F19422@lifesci.dundee.ac.uk"><omeroweb.log></span>_______________________________________________<br class="">
ome-devel mailing list<br class="">
<a href="mailto:ome-devel@lists.openmicroscopy.org.uk" class="">ome-devel@lists.openmicroscopy.org.uk</a><br class="">
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
<br>
<span style="font-size:10pt;">The University of Dundee is a registered Scottish Charity, No: SC015096</span>
</body>
</html>