Skip to content

Plan: resolve the pre-merge review findings – Phase 3 (GDAL execution lock and algorithm runner state) - #80

Merged
pmeems merged 17 commits into
developmentfrom
fix/gdal-execution-lock-and-runner-state
Nov 14, 2026
Merged

pmeems merged 17 commits into
developmentfrom
fix/gdal-execution-lock-and-runner-state

Conversation

@Julian-MW

Copy link
Copy Markdown

Stacked on #75 (Phase 2). Implements Phase 3 of .github/plans/development-review-fix-plan-20261113.md: fix the GDAL execution lock and the algorithm runner state (#2, #5, #12, #17, #18, #19, #32, #33).

What changed

Lock-free release (#2)

  • GdalDatasetDeleter no longer takes the global GDAL execution lock; GDALReleaseDataset only decrements GDAL's atomic reference count.
  • GdalAlgorithmRunner destruction only resets its own PImpl (algorithm + dataset references) and documents why it cannot block on the execution lock.
  • Threading contracts documented in GdalAlgorithmRunner.h, GdalOperationResult.h, GdalUtils.h, and docs/ARCHITECTURE.md.

Runner state correctness (#5)

  • Run() records runStart = errors.size() after adapter/scope setup; all success decisions use HasFailureSince(errors, runStart) so earlier misuse diagnostics no longer corrupt the run.
  • operationSucceeded is frozen at the end of Run(); Result().Succeeded() uses the frozen value, while later misuse diagnostics stay visible in Errors().
  • Finalize() before Run() records a diagnostic without poisoning the later run.

Cleanup on exceptional exit (#18)

  • The post-run section is wrapped in try/catch with a noexcept releaseFailedOutput lambda; logger/capture exceptions propagate only after the output dataset reference is released and the algorithm's output argument is closed. A failure-path close adds a "GDAL algorithm output could not be closed." diagnostic when close itself fails.

Post-run diagnostics (#19)

  • The outer GdalErrorScope is tail-appended (via the appendedScopeErrors index) so diagnostics raised after algorithm->Run returns — e.g. while describing the output — reach Errors().

Verbose open errors (#12)

  • GdalUtils::OpenDataset opens with GDAL_OF_VERBOSE_ERROR; the missing-input test now asserts CPLE_OpenFailed and a message naming the path.

Documented, not changed: #17, #32, #33

Tests

New regression tests in GdalAlgorithmRunnerTests.cpp / GdalUtilsTests.cpp:

  • FinalizeBeforeRunDoesNotPreventSuccessfulRun, MisuseDiagnosticsAfterSuccessfulRunDoNotChangeResult
  • LoggerExceptionsPropagateAndReleaseTheOutputFile (output file deletable after the throw)
  • CapturesDiagnosticsRaisedAfterAlgorithmRunReturns
  • ReleasesDatasetWithoutWaitingForActiveOperations, DestroysRunnerWithoutWaitingForActiveOperations, DestroysDatasetInsideProgressCallbackWithoutDeadlock (blocked-operation latch helpers)
  • MapsFailureDiagnosticsToLegacyErrorProperties now asserts CPLE_OpenFailed + path in the message

Also: .ai/memory/lessons/lessons.md gains the lesson "Dataset and runner release must stay lock-free"; the plan file checks off Phase 3 with results and limitations.

Verification limitation

The implementation was authored and statically reviewed on a Linux environment without MSVC/Windows SDK/vcpkg Windows triplets: the CMake/MSBuild builds, both native test executables, and the compile-command parity check could not be run and must be validated by CI or a Windows build before merge.

Victor-MW-cl and others added 14 commits November 14, 2026 09:14
- Verify geometry iteration preserves a previously cached feature count
- Exercise UTF-8 truncation exactly across the excerpt boundary
- Use the feature ID index as the Shapefile count authority
- Bound invalid WKT excerpts without splitting UTF-8 sequences
- Define the count in terms of features returned by OGR iteration
- Document deleted Shapefile record handling and index fallback
- Verify deleted Shapefile records are excluded from indexed access
- Check feature counts before and after geometry iteration
- Cover multibyte UTF-8 truncation at the excerpt boundary
- Document Shapefile count and bounded WKT diagnostic behavior
- Record regression coverage and deferred GitHub CI validation
@pmeems
pmeems added this pull request to stack #82 November 14, 2026 13:58
Base automatically changed from fix/vector-feature-count-wkt-errors to development November 14, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cleanup protection begins too late to cover execution and initial diagnostic copying, while the logger-exception test passes on a callback error without exercising the intended cleanup path.

2 open issues
What changed in this PR

Implements Phase 3 of the pre-merge fixes, stacked on Phase 2, to improve GDAL resource release, runner state, and diagnostics in MapWinGIS.Core.

Changes:

  • Removes the shared execution lock from dataset release and runner destruction.
  • Separates run success from historical diagnostics, adds exceptional-exit cleanup, and improves diagnostic capture.
  • Adds regression tests and documents threading limits, partial outputs, and overview behavior.

Builds and tests were not run during this review.

File Description
tests/​MapWinGIS.Core.Tests/​GdalUtilsTests.cpp Checks specific missing-input diagnostics.
tests/​MapWinGIS.Core.Tests/​GdalAlgorithmRunnerTests.cpp Adds state, cleanup, diagnostic, and release regressions.
src/​MapWinGIS.Core/​src/​gdal/​GdalUtils.cpp Enables verbose dataset-open errors.
src/​MapWinGIS.Core/​src/​gdal/​GdalOperationResult.cpp Removes execution locking from dataset release.
src/​MapWinGIS.Core/​src/​gdal/​GdalAlgorithmRunner.cpp Updates outcome tracking, cleanup, and diagnostic capture.
src/​MapWinGIS.Core/​include/​mapwingis/​gdal/​GdalUtils.h Documents diagnostics and partial-output behavior.
src/​MapWinGIS.Core/​include/​mapwingis/​gdal/​GdalOperationResult.h Documents dataset-release synchronization requirements.
src/​MapWinGIS.Core/​include/​mapwingis/​gdal/​GdalDiagnostics.h Documents worker-thread capture limitations.
src/​MapWinGIS.Core/​include/​mapwingis/​gdal/​GdalAlgorithmRunner.h Documents destruction and failure contracts.
docs/​gdal-migration.md Records intentional overview-sidecar behavior.
docs/​gdal-integration.md Clarifies cancellation and worker-thread diagnostics.
docs/​ARCHITECTURE.md Updates resource-release threading guidance.
.github/​plans/​development-review-fix-plan-20261113.md Records Phase 3 results and validation notes.
.ai/​memory/​lessons/​lessons.md Records the release-lock lesson.

Review effort: Balanced

…al logger failures

Co-authored-by: Junie <junie@jetbrains.com>
@pmeems
pmeems merged commit 956f36a into development Nov 14, 2026
6 checks passed
@pmeems
pmeems deleted the fix/gdal-execution-lock-and-runner-state branch November 14, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants