Skip to content

feat: [OCISDEV-855] receivedsharecache: retry on transient storage errors in CAS loop - #657

Merged
mklos-kw merged 7 commits into
mainfrom
feat/ocisdev-855-2
Jul 22, 2026
Merged

mklos-kw merged 7 commits into
mainfrom
feat/ocisdev-855-2

Conversation

@mklos-kw

Copy link
Copy Markdown
Member

No description provided.

@kw-security

kw-security commented Jul 14, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@mklos-kw
mklos-kw force-pushed the feat/ocisdev-855-2 branch from 1a0308f to 4fe0540 Compare July 15, 2026 07:48
@mklos-kw
mklos-kw marked this pull request as ready for review July 21, 2026 11:40
@mklos-kw
mklos-kw requested a review from a team as a code owner July 21, 2026 11:40
@mklos-kw
mklos-kw force-pushed the feat/ocisdev-855-2 branch from a6710ac to 58e4274 Compare July 21, 2026 12:08
@mklos-kw mklos-kw changed the title feat: OCISDEV-855 feat: [OCISDEV-855] receivedsharecache: retry on transient storage errors in CAS loop Jul 21, 2026
mzner
mzner previously approved these changes Jul 21, 2026
jvillafanez
jvillafanez previously approved these changes Jul 21, 2026

@jvillafanez jvillafanez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some minor comments and ideas, but it looks fine.

Comment on lines +183 to +186
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Grab lock")
unlock := c.lockUser(userID)
span.End()
span.SetAttributes(attribute.String("cs3.userid", userID))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this has been touched....
I think we decided against this pattern. Either you time the whole List function, or you time inside the lockUser function (which will also time all the calls going through that function). In this particular you case, you're only measuring this particular lockUser call, which might be confusing because other calls won't appear.
In addition, the SetAttributes might not have any effect because the span has ended.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thank you, fixed

span.SetAttributes(attribute.String("cs3.userid", userID))
defer unlock()

err := c.syncWithLock(ctx, userID)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might need some name change or a comment. I thought it had to do something with locking or it might be a potential blocking call.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. Renamed syncWithLock() to syncIfStale() + lock comment - to follows convention from Designing Data Intensive Applications (DDIA) ch. 5 Replication.

return isTooEarly || isInternal
}

func (c *Cache) retryPersist(ctx context.Context, span trace.Span, userID, spaceID string, persistFunc func() error) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any advantage of passing the span as parameter?
In theory, if you need access to the span, you should get the span from the context. In general, I think that whoever creates a new span is responsible for filling it and close it, so span shouldn't leave the function that has created it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed, thank you

Comment thread pkg/storage/utils/metadata/cs3.go Outdated

// CS3 represents a metadata storage with a cs3 storage backend
type CS3 struct {
log zerolog.Logger

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any chance to get the logger from the context? In theory, it could provide additional information from the context (usually associated to the request).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed, thank you

@mklos-kw
mklos-kw dismissed stale reviews from jvillafanez and mzner via 7936a29 July 21, 2026 19:38
@mklos-kw
mklos-kw force-pushed the feat/ocisdev-855-2 branch from 7936a29 to 8ee685d Compare July 21, 2026 19:38
jvillafanez
jvillafanez previously approved these changes Jul 22, 2026

@jvillafanez jvillafanez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a comment for future PRs. It's a bit out of scope for this one.

Comment on lines +268 to +272
if !isSyncTransient(serr) {
span.RecordError(serr)
span.SetStatus(codes.Error, serr.Error())
log.Error().Int("attempt", attempt).Err(serr).Msg("lost update: re-read failed, aborting")
return serr

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's weird that we only set the error and status code of the span here. If the caller creates the span, it should be the caller the one closing it AND setting the appropriate status code. I think all the errors returned by the function should be registered, not just this one.

@2403905

2403905 commented Jul 22, 2026

Copy link
Copy Markdown
  1. So many debug logs in a PR log.Debug(). I hope later we can clean up it.
  2. The change log is missing

@mklos-kw
mklos-kw merged commit d084587 into main Jul 22, 2026
16 checks passed
@mklos-kw
mklos-kw deleted the feat/ocisdev-855-2 branch July 22, 2026 18:19
mklos-kw added a commit that referenced this pull request Aug 13, 2026
…t storage errors in CAS loop (#709)

* feat: [OCISDEV-855] receivedsharecache: retry on transient storage errors in CAS loop (#657)

* fix: ocisdev-855, cs3/decomposefs transactional concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload

* fix: [OCISDEV-855] stable-8.0 build: NewTooEarly→NewAborted, serialize Download in concurrent test

status.NewTooEarly was added after stable-8.0 branched; map IsTooEarly to
NewAborted instead (same retry semantics for the client).

DiskStorage.Upload on stable-8.0 uses os.WriteFile (not renameio), so
concurrent Download calls can read a partial file. Add a mutex to
barrierStorage that serializes Upload/Download pairs in the test.

* fix: [OCISDEV-855] stable-8.0: drop IsResourceProcessing (added after branch cut)
mklos-kw added a commit that referenced this pull request Aug 13, 2026
…t storage errors in CAS loop (#710)

* feat: [OCISDEV-855] receivedsharecache: retry on transient storage errors in CAS loop (#657)

* fix: ocisdev-855, cs3/decomposefs transactional concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload

* fix: [OCISDEV-855] stable-8.1 build: NewTooEarly→NewAborted, serialize Download in concurrent test

status.NewTooEarly was added after stable-8.1 branched; map IsTooEarly to
NewAborted instead (same retry semantics for the client).

DiskStorage.Upload on stable-8.1 uses os.WriteFile (not renameio), so
concurrent Download calls can read a partial file. Add a mutex to
barrierStorage that serializes Upload/Download pairs in the test.

* fix: [OCISDEV-855] stable-8.1: drop IsResourceProcessing (added after branch cut)
mklos-kw added a commit that referenced this pull request Aug 13, 2026
…rors in CAS loop (#657) (#711)

* fix: ocisdev-855, cs3/decomposefs transactional concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload
mklos-kw added a commit that referenced this pull request Sep 29, 2026
…rors in CAS loop (#657)

* fix: ocisdev-855, cs3/decomposefs transactional concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload

* feat: logs and cleanup

* feat: cleanup

* feat: review fixes

* feat: cleanup in tracing
mklos-kw added a commit that referenced this pull request Sep 29, 2026
…rors in CAS loop (#657)

* fix: ocisdev-855, cs3/decomposefs transactional concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload

* feat: logs and cleanup

* feat: cleanup

* feat: review fixes

* feat: cleanup in tracing

# Conflicts:
#	internal/grpc/services/storageprovider/storageprovider.go
#	pkg/rhttp/datatx/utils/download/download.go
#	pkg/share/manager/jsoncs3/receivedsharecache/receivedsharecache_test.go
mklos-kw added a commit that referenced this pull request Oct 8, 2026
…rors in CAS loop (#657)

* fix: ocisdev-855, cs3/decomposefs transactional concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload

* fix: ocisdev-855, cs3/decomposefs optimistic-abort concurent upload

* feat: logs and cleanup

* feat: cleanup

* feat: review fixes

* feat: cleanup in tracing

# Conflicts:
#	internal/grpc/services/storageprovider/storageprovider.go
#	pkg/rhttp/datatx/utils/download/download.go
#	pkg/share/manager/jsoncs3/receivedsharecache/receivedsharecache_test.go
2403905 added a commit that referenced this pull request Nov 20, 2026
… receivedsharecache retry path (#830)

Backport of #751 from stable-8.0 (cherry picked from commit e28d93d).

Main had the first version of the retry loop (#657). This commit replaces it
with the cas package and the fixes of #751. The fix for OCISDEV-1685 needs them.

Differences from #751:

1. The jsoncs3 cache packages, the cas package, the test helpers and the
   integration test come unchanged from #751.
2. storageprovider.go keeps the IsTooEarly case of main. It adds the cases
   Aborted and AlreadyExists.
3. The TooEarly check in Decomposedfs.Download is not added. Main already
   returns ResourceProcessing for a node in processing.
4. The changes in tree.go and the new tests for tree.go, decomposedfs.go and
   storageprovider.go are not added. Main changed the upload path with the
   upload coordinator, and the tests do not fit.

Co-authored-by: Michal Klos <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
2403905 added a commit that referenced this pull request Nov 20, 2026
… failures in receivedsharecache retry path (#831)

Backport of #751 from stable-8.0 (cherry picked from commit e28d93d).

Main had the first version of the retry loop (#657). This commit replaces it
with the cas package and the fixes of #751. The fix for OCISDEV-1685 needs them.

Differences from #751:

1. The jsoncs3 cache packages, the cas package, the test helpers and the
   integration test come unchanged from #751.
2. storageprovider.go keeps the IsTooEarly case of main. It adds the cases
   Aborted and AlreadyExists.
3. The TooEarly check in Decomposedfs.Download is not added. Main already
   returns ResourceProcessing for a node in processing.
4. The changes in tree.go and the new tests for tree.go, decomposedfs.go and
   storageprovider.go are not added. Main changed the upload path with the
   upload coordinator, and the tests do not fit.

Co-authored-by: Michal Klos <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
2403905 added a commit that referenced this pull request Nov 24, 2026
… failures in receivedsharecache retry path (#843)

Backport of #751 from stable-8.0 (cherry picked from commit e28d93d).

Main had the first version of the retry loop (#657). This commit replaces it
with the cas package and the fixes of #751. The fix for OCISDEV-1685 needs them.

Differences from #751:

1. The jsoncs3 cache packages, the cas package, the test helpers and the
   integration test come unchanged from #751.
2. storageprovider.go keeps the IsTooEarly case of main. It adds the cases
   Aborted and AlreadyExists.
3. The TooEarly check in Decomposedfs.Download is not added. Main already
   returns ResourceProcessing for a node in processing.
4. The changes in tree.go and the new tests for tree.go, decomposedfs.go and
   storageprovider.go are not added. Main changed the upload path with the
   upload coordinator, and the tests do not fit.

Co-authored-by: Michal Klos <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>

Backport of #831 to stable-8.2.
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.

7 participants