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

feat: [OCISDEV-855] receivedsharecache: retry on transient storage errors in CAS loop#657
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
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