Skip to content

Add ClearLogAsync method to JournaledGrain#9849

Merged
ReubenBond merged 6 commits intodotnet:mainfrom
m3nax:feat/add-clearlog-to-journaledgrain
Feb 15, 2026
Merged

Add ClearLogAsync method to JournaledGrain#9849
ReubenBond merged 6 commits intodotnet:mainfrom
m3nax:feat/add-clearlog-to-journaledgrain

Conversation

@m3nax
Copy link
Copy Markdown
Contributor

@m3nax m3nax commented Dec 17, 2025

Added ClearLogAsync to the JournaledGrain in order to completely erase the stored data of the grain
Implemented the method in StateStorage and LogStorage
Added the method to be implemented in the ICustomStorageInterface interface with a default implementation in order to avoid breaking changes

REF: #8408

Microsoft Reviewers: Open in CodeFlow

@m3nax m3nax changed the title Added ClearLogAsync method to JournaledGrain Add ClearLogAsync method to JournaledGrain Dec 17, 2025
@m3nax m3nax marked this pull request as ready for review January 7, 2026 20:56
Copilot AI review requested due to automatic review settings January 7, 2026 20:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a ClearLogAsync method to JournaledGrain to enable complete erasure of stored grain data. This addresses a feature request (#8408) for a way to reset event-sourced grains to their initial state.

Key Changes:

  • Added ClearLogAsync method to the JournaledGrain base class and ILogViewUpdate interface
  • Implemented ClearLogAsync in StateStorage, LogStorage, and CustomStorage adaptors
  • Added backward-compatible default implementation to ICustomStorageInterface using C# default interface methods

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Orleans.EventSourcing/JournaledGrain.cs Exposes protected ClearLogAsync method for grain subclasses
src/Orleans.EventSourcing/LogConsistency/ILogViewAdaptor.cs Adds ClearLogAsync to the ILogViewUpdate interface
src/Orleans.EventSourcing/StateStorage/LogViewAdaptor.cs Implements clear logic for state storage backend
src/Orleans.EventSourcing/LogStorage/LogViewAdaptor.cs Implements clear logic for log storage backend
src/Orleans.EventSourcing/CustomStorage/LogViewAdaptor.cs Implements clear logic for custom storage backend
src/Orleans.EventSourcing/CustomStorage/ICustomStorageInterface.cs Adds default ClearStoredState method with NotSupportedException
src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs Adds base implementation, ResetTentativeState helper, and caches initial state

Comment thread src/Orleans.EventSourcing/LogConsistency/ILogViewAdaptor.cs Outdated
Comment thread src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs Outdated
Comment thread src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs Outdated
@ReubenBond ReubenBond force-pushed the feat/add-clearlog-to-journaledgrain branch from 5aca271 to 007619d Compare February 14, 2026 14:52
@ReubenBond
Copy link
Copy Markdown
Member

@m3nax I added a commit to serialize clear operations w.r.t other pending operations and rebased.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Comment thread src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs
Comment thread src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs Outdated
Comment thread src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs Outdated
Comment thread src/Orleans.EventSourcing/LogConsistency/ILogViewAdaptor.cs Outdated
m3nax and others added 5 commits February 14, 2026 16:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Route ClearLogAsync through PrimaryBasedLogViewAdaptor worker to avoid races with pending updates.

- Introduce provider ClearPrimaryLogAsync hooks and explicit cancellation checks for providers without token-aware clear APIs.

- Expose Clear() on log test grains and add non-Azure LogTestGrainClearTests for DefaultStorage, SharedLogStorage, and CustomStoragePrimaryCluster.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond ReubenBond force-pushed the feat/add-clearlog-to-journaledgrain branch from 007619d to 4ff73cc Compare February 15, 2026 00:40
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@m3nax
Copy link
Copy Markdown
Contributor Author

m3nax commented Feb 15, 2026

@m3nax I added a commit to serialize clear operations w.r.t other pending operations and rebased.

Thank you for reviewing my pr

@ReubenBond ReubenBond added this pull request to the merge queue Feb 15, 2026
Merged via the queue into dotnet:main with commit bf8dd71 Feb 15, 2026
59 checks passed
@m3nax m3nax deleted the feat/add-clearlog-to-journaledgrain branch February 16, 2026 09:50
rkargMsft pushed a commit to rkargMsft/orleans that referenced this pull request Feb 27, 2026
* Added ClearLogAsync method to JournaledGrain

* Added supporto for ClearLog to ICustomStorageInterface<TLogView, TLogEntry>

* Fixed property naming

* Update src/Orleans.EventSourcing/LogConsistency/ILogViewAdaptor.cs

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

* Serialize ClearLog and add integration tests

- Route ClearLogAsync through PrimaryBasedLogViewAdaptor worker to avoid races with pending updates.

- Introduce provider ClearPrimaryLogAsync hooks and explicit cancellation checks for providers without token-aware clear APIs.

- Expose Clear() on log test grains and add non-Azure LogTestGrainClearTests for DefaultStorage, SharedLogStorage, and CustomStoragePrimaryCluster.

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

* Address PR dotnet#9849 feedback

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

---------

Co-authored-by: Copilot <175728472+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 19, 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