Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#795 closed defect (fixed)

Connection closed on parallel WCS requests when one query fails

Reported by: Piero Campalani Owned by: Dimitar Misev
Priority: major Milestone: 9.0.x
Component: petascope Version: development
Keywords: parallel psql exception Cc: damiano, Dimitar Misev, mantovani, Peter Baumann
Complexity: Medium

Description

There is a thread-safety issue in the handling of Postgres connections that is revealed when due parallel queries are run, but one of them fails (by requesting a non-existent coverage).

I tried sending N requests in parallel, half of them with wrong coverage ID:

$ declare -a URLLIST=(\
  'http://localhost:8080/rasdaman/ows/wcs2?service=WCS&version=2.0.1&request=GetCoverage&coverageId=irr_cube_scam&subset=E(80000,100000)&subset=N(5100000,5124000)&subset=ansi(148654)&scaleextent=E(0:0)' \
  'http://localhost:8080/rasdaman/ows/wcs2?service=WCS&version=2.0.1&request=GetCoverage&coverageId=irr_cube_2&subset=E(80000,100000)&subset=N(5100000,5124000)&subset=ansi(148654)&scaleextent=E(0:0)')
for i in {0..10}; do ( (( $i % 2 ==  0)); wget ${URLLIST[$?]} -O out${i}.xml &) ; done

(thanks MEEO Srl for reporting), it happens that a closed connection is trying to get used:

ERROR [14:05:29] DbMetadataSource@1324: Failed reading the coverage metadata
org.postgresql.util.PSQLException: This connection has been closed.
...
    at petascope.core.DbMetadataSource.read(DbMetadataSource.java:941)
    at petascope.util.WcsUtil.getMetadata(WcsUtil.java:105)
    at petascope.wcs2.parsers.GetCoverageMetadata.<init>(GetCoverageMetadata.java:98)
    at petascope.wcs2.extensions.GmlFormatExtension.handle(GmlFormatExtension.java:66)
    at petascope.wcs2.handlers.GetCoverageHandler.handle(GetCoverageHandler.java:53)
...

I tried up to 20 queries but can't reproduce it.

Apparently this affect v9.0.2 only, while v9.0.1 is still ok.
I wonder if changeset:216edb0 ('ticket:713 - fix database connection leaks in petascope') has some responsibility here or not.

Change History (15)

comment:1 by damiano, 10 years ago

Cc: mantovani added

comment:2 by Dimitar Misev, 10 years ago

Owner: changed from Piero Campalani to Dimitar Misev
Status: newassigned

comment:3 by Dimitar Misev, 10 years ago

Damiano, you have postgresql 8.4?

comment:4 by damiano, 10 years ago

postgresql-libs-8.4.20-1.el6_5.x86_64
postgresql-server-8.4.20-1.el6_5.x86_64
postgresql-8.4.20-1.el6_5.x86_64

comment:5 by Dimitar Misev, 10 years ago

Can't reproduce it either. How did you test Damiano?

comment:6 by Dimitar Misev, 10 years ago

Cc: Peter Baumann added

I submitted a patch fix

comment:7 by mantovani, 10 years ago

are you going to build and realease the 9.0.3 RPM package?

comment:8 by Dimitar Misev, 10 years ago

Once the patch is applied, yes. If it's urgent you could easily build the petascope war, I don't have a VM with Java 6 at the moment.

comment:9 by mantovani, 10 years ago

It is urgent and, you know, our update/upgrade process is based on RPM packages: the sooner you build them, the better it is

comment:10 by Dimitar Misev, 10 years ago

Yes I understand that. I'm sure Peter will soon check and apply the patch.

comment:11 by mantovani, 10 years ago

thanks

comment:12 by Peter Baumann, 10 years ago

at OGC TC meeting. Can do on Monday.

comment:13 by mantovani, 10 years ago

fine with me. Enjoy your OGC meeting.

comment:14 by Dimitar Misev, 10 years ago

Resolution: fixed
Status: assignedclosed

comment:15 by damiano, 10 years ago

I can confirm that the issue is fixed
New petascope rpm (9.0.3) works fine

Damiano

Note: See TracTickets for help on using tickets.