Skip to content

Fix shared drive failures caused by multiple share-interact permission docs being created for the same sharing#4760

Merged
shepilov merged 8 commits into
masterfrom
fix/parallel_permission_doc_creation
May 20, 2026
Merged

Fix shared drive failures caused by multiple share-interact permission docs being created for the same sharing#4760
shepilov merged 8 commits into
masterfrom
fix/parallel_permission_doc_creation

Conversation

@shepilov
Copy link
Copy Markdown
Contributor

Summary

The issue could happen when drive sharing invitations were prepared concurrently: several members could trigger interact-code creation at the same time, and CouchDB generated different permission document IDs. Later reads could pick a partial permission doc, causing missing drive tokens and errors like “member was not found”

Changes

  • Use a canonical deterministic ID for share-interact permission docs.
  • Repair existing duplicate share-interact permission docs by merging codes into the canonical doc and deleting legacy duplicates.
  • Make GetForShareInteract repair duplicates before returning permissions.
  • Serialize GetInteractCode with the existing instance lock to avoid local concurrent writes for the same sharing.

@shepilov shepilov requested a review from a team as a code owner May 18, 2026 17:02
@shepilov shepilov force-pushed the fix/parallel_permission_doc_creation branch 2 times, most recently from 3ae6389 to 986e915 Compare May 19, 2026 07:59
@shepilov shepilov force-pushed the fix/parallel_permission_doc_creation branch from 986e915 to fd87add Compare May 19, 2026 08:19
@shepilov shepilov force-pushed the fix/parallel_permission_doc_creation branch from 7977e97 to eb951fb Compare May 19, 2026 10:39
Comment thread model/permission/permissions.go
Comment thread model/permission/permissions.go Outdated
Comment thread model/permission/permissions.go Outdated
Comment thread model/permission/permissions.go Outdated
p := &perms[i]
if p.ID() == canonicalID {
hasCanonical = true
// If the canonical doc is expired, update that doc ID but rebuild its content from non-expired docs.
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.

Are we really updating the ID? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mmm, why do you think so? The merged doc is already initialized with canonicalID

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'm just reading the comment that says we update the doc ID. I was surprised since I didn't see where we were editing the ID.

Comment thread model/permission/permissions.go Outdated
Comment thread model/permission/permissions.go
@shepilov shepilov force-pushed the fix/parallel_permission_doc_creation branch from eb951fb to fdab8b5 Compare May 19, 2026 11:03
@shepilov shepilov force-pushed the fix/parallel_permission_doc_creation branch from fdab8b5 to e40924d Compare May 19, 2026 11:12
@shepilov shepilov merged commit 0dc241c into master May 20, 2026
4 checks passed
@shepilov shepilov deleted the fix/parallel_permission_doc_creation branch May 20, 2026 08:37
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.

2 participants