Skip to content

[Bug]: oc_share table has duplicate rows for the same share #53970

@Antreesy

Description

@Antreesy

⚠️ This issue respects the following points: ⚠️

Bug description

There might be a race condition in ShareProvider, where several requests in parallel check if share exists in DB, and create it otherwise. In this case, there could be several new entries created, each with unique id, but all pointing to the same share.
If user tries to modify/leave share, it will modify the first row only, keeping the second intact. That way, you can never get rid of it.

Steps to reproduce

Don't have clear steps, but example behaviour sounds logical:

  1. Sharing a file in Talk creates a parent entry with share_type 10 and file_target /{TALK_PLACEHOLDER}/file.md
  2. User access conversation with shared file as last message, filesystem is mounted from conversations request and chat messages request
  3. This creates two entries in DB with share_type 11 and file_target /Talk/file.md (best reproducible when PHP debugger was enabled, but also occurs on prod/daily instances)
    3.1. Worse case if user at some point changed the attachments folder, so initial entry is share_type 11 and file_target /Talk/file.md, and duplicates are share_type 11 and file_target /SomeOtherPath/file.md. Modifications will touch only first occurence of /SomeOtherPath/file.md

Expected behavior

Some sort of transactional lock (to write in DB only once) in place

Nextcloud Server version

master

Details

Operating system

None

PHP engine version

None

Web server

None

Database engine version

None

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

List of activated Apps

Nextcloud Signing status

Nextcloud Logs

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    📄 To do (~10 entries)

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions