Hi ThinkGeo team,
Separate FileGeoDatabaseFeatureSource instances pointing to the same database can
interfere with each other’s native resource lifetime. We observed process termination
with this finalizer exception:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Geodatabase'.
at Esri.FileGDB.Table.Shutdown()
at Esri.FileGDB.Table.Dispose(Boolean A_0)
at Esri.FileGDB.Table.Finalize()
at System.GC.RunFinalizers()
Inspected versions: ThinkGeo.FileGeoDatabase 15.0.0-beta233 and
Esri.FileGDBAPI.dll from ThinkGeo.Dependency.FileGeoDatabase 14.5.4.
The findings below come from assembly inspection.
Lifetime and synchronization findings:
FileGeoDatabaseFeatureSourcedelegates toThinkGeoObfuscated.j.jt, which has
process-wide geodatabase and table caches. Separate sources for the same path/table
reuse the same native objects. Closing a source removes and disposes its cached
table and, when the table dictionary becomes empty, the geodatabase. There is no
source-owner reference count in this path.- The table-cache lookup checks for an existing entry before taking the shared lock;
the subsequent lockedOpenTable/assignment does not recheck it. Concurrent opens
can overwrite a cached table without disposing the previous object. GetFirstFeaturesWellKnownTypeCoreopens an additional, uncached table and searches
its first row. This operation does not hold the shared lock across opening, reading
and cleanup. Another source can close the cached geodatabase during that operation.- The cleanup helper catches exceptions from both
Table.Close()andDispose().
In the Esri wrapper,Table.Shutdown()accessesGeodatabase.NativeGeodatabase,
whose getter throws when the database is disposed. If this makesTable.Dispose()
fail, it never reachesGC.SuppressFinalize; the later finalizer can throw again.
Also,Geodatabase.OpenTable()allocates a table before the native open and does
not dispose that table on an open failure.
Lock contention: full-feature reads hold the shared lock for the entire scan.
A background GetAllFeatures() on one source can therefore block a metadata open
on another source. Separate layer instances do not isolate these operations.
Suggested SDK reproduction cases (not yet run):
- Repeatedly open/read/close separate
FileGeoDatabaseFeatureLayerinstances for
the same path/table on concurrent workers. IncludeQueryTools.GetColumns(),
QueryTools.GetFirstFeaturesWellKnownType()and
FeatureSource.GetAllFeatures(ReturningColumnsType.NoColumns). Force collection
and wait for pending finalizers after each completed batch in the test process
to expose orphaned tables sooner. - Overlap a geometry-type probe on one source with closing another source for the
same database. Verify that the probe’s uncached table remains valid through cleanup. - Exercise a failing table open followed by database cleanup and GC; verify that
a partially opened table cannot later terminate the process.
Could you investigate cache ownership/synchronization and the Esri wrapper’s failed
open/disposal paths? Closing one source should not invalidate another source’s active
native objects, and finalization should not throw after database cleanup. Please
also clarify the supported concurrency contract for separate File GDB sources and
whether full reads must serialize metadata access across sources.
Thanks!