i2b2 Sponsored Project/s:
This issue was reported by Robert Lodahl from the University Medical Center Gottingen.
When running multiple parallel queries requesting a PDO, the CRC will return an error. It appears, for all parallel queries run by the custom plugin, the same connection is used.
Upon further investigation, Robert has located the problem to the local temporary tables (like #temp_fact_param_table in this case) are only local for every connection, not per statement. So the first query starts, creating the table, wanting to execute something using this table, while the second query starts and drops the table (marked in bold). Obviously an exception occurs because the table no longer exists.
The ERROR message that appears is:
"Caused by: org.postgresql.util.PSQLException: ERROR: relation "temp_fact_param_table" does not exist“
The exception can be traced back to the part of the code:
edu.harvard.i2b2.crc.dao.pdo.PdoQueryConceptDao.getConceptByFact(PdoQueryConceptDao.java:346)
The section of code that appears to be causing the problem can be seen in the attached document.
ATTACHMENTS:
EMAIL_Parallel_Queries_Error.pdf = original email from Robert.
{"report":{"fcp":961.0999994277954,"ttfb":318.0999994277954,"pageVisibility":"visible","entityId":10960,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"6748b3b0-e8b0-4d42-90aa-384ddfda66a9","navigationType":0,"readyForUser":1020.6999998092651,"redirectCount":0,"resourceLoadedEnd":940.5,"resourceLoadedStart":343.5999994277954,"resourceTiming":[{"duration":11.90000057220459,"initiatorType":"link","name":"https://community.i2b2.org/jira/s/7fd763ecdf5ed1f47fc4d22fa8382e97-CDN/4x9nqn/820011/16zrvj4/49fa3aa3d35a2cc689cbf274e66cc41a/_/download/contextbatch/css/_super/batch.css","startTime":343.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":343.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":355.5,"responseStart":0,"secureConnectionStart":0},{"duration":12,"initiatorType":"link","name":"https://community.i2b2.org/jira/s/898b8076c5e82f53cd816ca393e45a56-CDN/4x9nqn/820011/16zrvj4/41b71ca9fb0eed92dc73e9510f2744ee/_/download/contextbatch/css/project.issue.navigator,jira.view.issue,jira.global,atl.general,-_super/batch.css?jira.create.linked.issue=true&richediton=true&whisper-enabled=true","startTime":343.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":343.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":355.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":343.5,"initiatorType":"script","name":"https://community.i2b2.org/jira/s/4c9c503fe98f210445831b0d7b0cdc33-CDN/4x9nqn/820011/16zrvj4/49fa3aa3d35a2cc689cbf274e66cc41a/_/download/contextbatch/js/_super/batch.js?locale=en-US","startTime":344.0999994277954,"connectEnd":564.8000001907349,"connectStart":541.5,"domainLookupEnd":541.5,"domainLookupStart":541.5,"fetchStart":344.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":565.8999996185303,"responseEnd":687.5999994277954,"responseStart":604,"secureConnectionStart":552.6999998092651},{"duration":314.70000076293945,"initiatorType":"script","name":"https://community.i2b2.org/jira/s/694e598c1ae48b0f96655173631cd247-CDN/4x9nqn/820011/16zrvj4/41b71ca9fb0eed92dc73e9510f2744ee/_/download/contextbatch/js/project.issue.navigator,jira.view.issue,jira.global,atl.general,-_super/batch.js?jira.create.linked.issue=true&locale=en-US&richediton=true&whisper-enabled=true","startTime":344.5999994277954,"connectEnd":575.1999998092651,"connectStart":555.1999998092651,"domainLookupEnd":555.1999998092651,"domainLookupStart":555.1999998092651,"fetchStart":344.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":575.3000001907349,"responseEnd":659.3000001907349,"responseStart":609.5,"secureConnectionStart":565.0999994277954},{"duration":286.19999980926514,"initiatorType":"script","name":"https://community.i2b2.org/jira/s/53f54e0ac3f00bb56b136b4d2fff2853-CDN/4x9nqn/820011/16zrvj4/aae1242f5fc81cc6a5bb8bc963ccda29/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en-US","startTime":344.80000019073486,"connectEnd":582.6999998092651,"connectStart":558.5,"domainLookupEnd":558.5,"domainLookupStart":558.5,"fetchStart":344.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":612.8999996185303,"responseEnd":631,"responseStart":627.3000001907349,"secureConnectionStart":569.8000001907349},{"duration":284.5,"initiatorType":"script","name":"https://community.i2b2.org/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/4x9nqn/820011/16zrvj4/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":345,"connectEnd":603.8999996185303,"connectStart":565.3999996185303,"domainLookupEnd":565.3999996185303,"domainLookupStart":565.3000001907349,"fetchStart":345,"redirectEnd":0,"redirectStart":0,"requestStart":613.0999994277954,"responseEnd":629.5,"responseStart":626.3999996185303,"secureConnectionStart":574.8999996185303},{"duration":305.6000003814697,"initiatorType":"script","name":"https://community.i2b2.org/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/4x9nqn/820011/16zrvj4/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":345.19999980926514,"connectEnd":634.8999996185303,"connectStart":611.8000001907349,"domainLookupEnd":611.8000001907349,"domainLookupStart":611.8000001907349,"fetchStart":345.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":635,"responseEnd":650.8000001907349,"responseStart":647.5999994277954,"secureConnectionStart":623.0999994277954},{"duration":20.100000381469727,"initiatorType":"link","name":"https://community.i2b2.org/jira/s/30748292e4ca68be6947d7969829384b-CDN/4x9nqn/820011/16zrvj4/4f66da484ef7d95a2a604d3ab014374c/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":345.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":345.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":365.5,"responseStart":0,"secureConnectionStart":0},{"duration":318.3999996185303,"initiatorType":"script","name":"https://community.i2b2.org/jira/rest/api/1.0/shortcuts/820011/a9e270f026ecabffc9a59343e5439391/shortcuts.js?context=issuenavigation&context=issueaction","startTime":345.5,"connectEnd":649.3999996185303,"connectStart":629.0999994277954,"domainLookupEnd":629.0999994277954,"domainLookupStart":629.0999994277954,"fetchStart":345.5,"redirectEnd":0,"redirectStart":0,"requestStart":651.3000001907349,"responseEnd":663.8999996185303,"responseStart":662.5,"secureConnectionStart":638.5999994277954},{"duration":4.800000190734863,"initiatorType":"link","name":"https://community.i2b2.org/jira/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/4x9nqn/820011/16zrvj4/efa42a25652b26dfd802540c024826b3/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-jira.view.issue,-project.issue.navigator/batch.css?jira.create.linked.issue=true&richediton=true","startTime":450.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":450.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":455.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":449.20000076293945,"initiatorType":"script","name":"https://community.i2b2.org/jira/s/8087506fefd02b4096991c90836b49f6-CDN/4x9nqn/820011/16zrvj4/efa42a25652b26dfd802540c024826b3/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-jira.view.issue,-project.issue.navigator/batch.js?jira.create.linked.issue=true&locale=en-US&richediton=true","startTime":450.5999994277954,"connectEnd":885.1999998092651,"connectStart":862,"domainLookupEnd":862,"domainLookupStart":862,"fetchStart":450.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":885.3000001907349,"responseEnd":899.8000001907349,"responseStart":898.5999994277954,"secureConnectionStart":873.0999994277954},{"duration":463.4000005722046,"initiatorType":"script","name":"https://community.i2b2.org/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/4x9nqn/820011/16zrvj4/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":469.8999996185303,"connectEnd":919.3999996185303,"connectStart":896.5,"domainLookupEnd":896.5,"domainLookupStart":896.5,"fetchStart":469.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":919.3999996185303,"responseEnd":933.3000001907349,"responseStart":931.8000001907349,"secureConnectionStart":907.6999998092651},{"duration":430.19999980926514,"initiatorType":"script","name":"https://community.i2b2.org/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/4x9nqn/820011/16zrvj4/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":510.30000019073486,"connectEnd":927.6999998092651,"connectStart":906.8999996185303,"domainLookupEnd":906.8999996185303,"domainLookupStart":906.8999996185303,"fetchStart":510.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":928.3000001907349,"responseEnd":940.5,"responseStart":939,"secureConnectionStart":917.5}],"fetchStart":153,"domainLookupStart":154,"domainLookupEnd":242,"connectStart":242,"connectEnd":277,"secureConnectionStart":253,"requestStart":277,"responseStart":318,"responseEnd":510,"domLoading":322,"domInteractive":1078,"domContentLoadedEventStart":1078,"domContentLoadedEventEnd":1120,"domComplete":1762,"loadEventStart":1762,"loadEventEnd":1762,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1055.6999998092651},{"name":"bigPipe.sidebar-id.end","time":1056.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1056.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1057.6999998092651},{"name":"activityTabFullyLoaded","time":1138}],"measures":[],"correlationId":"a230d3bfc20431","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":220,"dbReadsTimeInMs":23,"dbConnsTimeInMs":56,"applicationHash":"0629dd8d260e3954ece49053e565d01dabe11609","experiments":[]}}
After further investigation I am quite sure that I found and resolved the issue.
The problem is: i2b2 creates it's temporary tables using this update statement:
"create table #temp_fact_param_table ( set_index int, char_param1 varchar(500) )"
i2b2 handles both sql-server and postgres in the same way. However they work quite different. While SqlServer creates local temporary tables using the "#"-sign in front of the table name, Postgres needs another update statement, explicitly naming that it is a temporary table to be created, see:
"create TEMPORARY table #temp_fact_param_table ( set_index int, char_param1 varchar(500) )"
This has resolved the issue for me, however, fixes in several files were needed.