Skip to content

DeleteStateOnClear support for AdoNet storage provider - #8535

Merged
ReubenBond merged 5 commits into
dotnet:mainfrom
modabas:main
Feb 15, 2026
Merged

ReubenBond merged 5 commits into
dotnet:mainfrom
modabas:main

Conversation

@modabas

@modabas modabas commented Jul 8, 2023 •

Copy link
Copy Markdown
Contributor

This PR is for issue #8059

Scripts are updated for Mssql and Potgresql only. Mysql and Oracle scripts need to be updated with a new step in OrleansQuery table with QueryKey = 'DeleteStorageKey'. Even so, current implementation should run as is, if DeleteStateOnClear option is not explicitly set to true.

There are some behaviour differences between DeleteStateOnClear option is set to false (same as current functionality and default option for this PR) and true. These are observed with both Postgresql and Mssql providers

Update on clear state =>

  1. If non existent (no rows in db table) state is cleared; inconsistent state exception is thrown
  2. If a non-cleared state is cleared; db version is incremented, State.ETag is set to new db version, db payload is set to null and State.RecordExists is set to false
  3. If a cleared state is cleared again; db version is incremented, State.ETag is set to new db version, db payload is set to null and State.RecordExists is set to false
    If grain whose state is cleared is reinitiated (or application restart), State.RecordExists is seen as true from grain

Delete on ClearState =>

  1. If non existent (no rows in db table) state is cleared; inconsistent state exception is thrown
  2. If a non-cleared state is cleared; db row is deleted, State.ETag is set to null and State.RecordExists is set to false
  3. If a cleared state is cleared again; inconsistent state exception is thrown
  4. If a state previously cleared with update is cleared; db row is deleted, State.ETag is set to null and State.RecordExists is set to false
    If grain whose state is cleared is reinitiated (or application restart), State.RecordExists is seen as false from grain
Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond self-assigned this Nov 1, 2023
@moldo92

moldo92 commented Feb 26, 2025

Copy link
Copy Markdown

Is this going to be added at some point?

modabas and others added 5 commits February 15, 2026 06:00
…ovider.

-add delete on clear script for postgresql
- Fix SQL Server DeleteStorageKey INSERT to use idempotent WHERE NOT EXISTS
  pattern consistent with other query inserts in the script
- Modernize RelationalStorageProviderQueries to use file-scoped namespace,
  ArgumentNullException.ThrowIfNull, and proper XML doc comments
- Fix comment formatting to follow C# conventions (space after //)
- Use nameof() in exception messages instead of string literals
- Add CommonFixture.GetStorageProvider overload with deleteStateOnClear param
- Add RelationalStorageTests support for deleteStateOnClear
- Add SqlServerStorageDeleteOnClearTests for low-level storage tests
- Add PostgreSqlStorageDeleteOnClearTests for low-level storage tests
- Add PersistenceGrainTests_SqlServer_DeleteStateOnClear for grain-level tests
- Add PersistenceGrainTests_Postgres_DeleteStateOnClear for grain-level tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond
ReubenBond enabled auto-merge February 15, 2026 14:01
@ReubenBond
ReubenBond added this pull request to the merge queue Feb 15, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Feb 15, 2026
* -add DeleteStateOnClear option and support to AdoNet grain storage provider.
-add delete on clear script for postgresql

* add delete on clear script for mssql

* fix returned version in postgresql delete on clear state script

* Fix and improve DeleteStateOnClear support for AdoNet storage provider

- Fix SQL Server DeleteStorageKey INSERT to use idempotent WHERE NOT EXISTS
  pattern consistent with other query inserts in the script
- Modernize RelationalStorageProviderQueries to use file-scoped namespace,
  ArgumentNullException.ThrowIfNull, and proper XML doc comments
- Fix comment formatting to follow C# conventions (space after //)
- Use nameof() in exception messages instead of string literals
- Add CommonFixture.GetStorageProvider overload with deleteStateOnClear param
- Add RelationalStorageTests support for deleteStateOnClear
- Add SqlServerStorageDeleteOnClearTests for low-level storage tests
- Add PostgreSqlStorageDeleteOnClearTests for low-level storage tests
- Add PersistenceGrainTests_SqlServer_DeleteStateOnClear for grain-level tests
- Add PersistenceGrainTests_Postgres_DeleteStateOnClear for grain-level tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add delete-on-clear support for MySQL and Oracle

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Reuben Bond <reuben.bond@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merged via the queue into dotnet:main with commit b8fbdd0 Feb 15, 2026
59 checks passed
rkargMsft pushed a commit to rkargMsft/orleans that referenced this pull request Feb 27, 2026
* -add DeleteStateOnClear option and support to AdoNet grain storage provider.
-add delete on clear script for postgresql

* add delete on clear script for mssql

* fix returned version in postgresql delete on clear state script

* Fix and improve DeleteStateOnClear support for AdoNet storage provider

- Fix SQL Server DeleteStorageKey INSERT to use idempotent WHERE NOT EXISTS
  pattern consistent with other query inserts in the script
- Modernize RelationalStorageProviderQueries to use file-scoped namespace,
  ArgumentNullException.ThrowIfNull, and proper XML doc comments
- Fix comment formatting to follow C# conventions (space after //)
- Use nameof() in exception messages instead of string literals
- Add CommonFixture.GetStorageProvider overload with deleteStateOnClear param
- Add RelationalStorageTests support for deleteStateOnClear
- Add SqlServerStorageDeleteOnClearTests for low-level storage tests
- Add PostgreSqlStorageDeleteOnClearTests for low-level storage tests
- Add PersistenceGrainTests_SqlServer_DeleteStateOnClear for grain-level tests
- Add PersistenceGrainTests_Postgres_DeleteStateOnClear for grain-level tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add delete-on-clear support for MySQL and Oracle

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Reuben Bond <reuben.bond@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants