NetCDFImageReader.forceSchemaCreation not thread safe

Description

UnidataImageReader.forceSchemaCreation contains this snippet:

[] typeNames = catalog.getTypeNames();
) {
tn : typeNames) {
(tn.equalsIgnoreCase(typeName)) {
;
}
}
}
catalog.createType(indexSchema);

The first check is being done to avoid the creation of a type that already exists. However, in a multi threaded environment, such as geoserver, this fails when two threads execute this concurrently.
Hence some type of locking is needed to solve this.

Environment

None

Activity

Show:
codehaus
April 10, 2015, 2:58 PM

CodeHaus Comment From: driesj - Time: Mon, 31 Mar 2014 02:17:07 -0500
---------------------
Hi Nicola,

I think geoserver sometimes uses different readers to read the same netcdf file. The issue is that reading a file also results in writes to this database on disk, so two readers accessing the same database without synchronization results in this error.

This bug occurred all the time, so it's not very rare, as long as you are in a multi-threaded environment such as geoserver.

codehaus
April 10, 2015, 2:58 PM

CodeHaus Comment From: dany111 - Time: Thu, 3 Apr 2014 04:55:26 -0500
---------------------
Hi Jeroen,

Quick question for investigation purposes:

Did you get this issue when dealing with a mosaic of NetCDF or when directly dealing with a NetCDF store? (Through the NetCDF Store plugin).

Cheers,

Daniele

codehaus
April 10, 2015, 2:58 PM

CodeHaus Comment From: driesj - Time: Thu, 3 Apr 2014 05:09:03 -0500
---------------------
Hi,

only when dealing with a mosaic I guess, I don't think I ever used the store directly.

codehaus
April 10, 2015, 2:58 PM

CodeHaus Comment From: driesj - Time: Tue, 19 Aug 2014 07:22:50 -0500
---------------------
Removed stack trace again, was caused by something else.

Andrea Aime
March 5, 2016, 2:14 PM

As far as I can tell the issue is still present in NetCDFImageReader

Assignee

Daniele Romagnoli

Reporter

codehaus

Triage

None

Affects versions

Priority

Medium
Configure