Text never releases its file lock when an editing session ends abnormally
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, mariadb, php, postgresql
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện kịch bản phiên bị kết thúc đột ngột, sau đó lần theo các đường dẫn teardown của Text và garbage collection của các phiên cũ. Tiếp theo, kiểm tra Cron\Unlock, ConfigService, FileLock, LockService::getDeprecatedLocks(), cùng với LocksRequest::update() và getLocksOlderThan() của files_lock. Công việc được xem là hoàn tất khi các phiên cũ và lock của chúng được giải phóng mà không làm hỏng các lock đang hoạt động hoặc khiến client bị kẹt với HTTP 423.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When a document is opened in Text, the app acquires a lock through files_lock. If the editing session ends abnormally — tab closed without a clean teardown, browser crash, session expiry — the lock is never released.
The failure is silent. A desktop client holding a newer local copy retries the upload and gets HTTP 423 Locked forever, with no actionable error surfaced in the web UI or in the client. Files whose local copy happens to be unchanged simply stop syncing in both directions, with no visible sign at all.
Orphan rows are also left behind in oc_text_sessions, with last_contact frozen at the moment the session died. Every stale lock we found had exactly one matching stale session, which suggests both are leaked by the same teardown path.
To Reproduce
- Open a Markdown file in Text.
- Kill the session abruptly (close the tab while editing, or let the session expire).
- Inspect
oc_files_lock: a row remains, withowner = "Text"and a negativettl. - On a desktop client syncing that folder, modify the same file locally.
- Watch the web server access log:
PUT /remote.php/dav/files/<user>/<path>→423, repeating indefinitely.
Expected behavior
The lock is released when the editing session ends, or at the latest when the stale session is garbage-collected.
Observed on a production instance
- 8 stale locks accumulated over 3 weeks, all
owner = "Text", the oldest 20 days old. - Each had a matching orphan row in
oc_text_sessions. - One file had a newer local copy: its desktop client issued a
PUTevery 2 hours and received423each time, for 19 consecutive days. - The 7 other files were silently out of sync — discovered only while investigating the first one.
Why nothing cleans this up
files_lock ships a cleanup job, OCA\FilesLock\Cron\Unlock, but with default settings it is a no-op:
ConfigServicedefaultslock_timeoutto'-1';FileLock::ETA_INFINITE === -1;LockService::getDeprecatedLocks()returns[]when the timeout equalsETA_INFINITE, so the job deletes nothing.
Setting a finite timeout re-arms the job and is an effective workaround:
occ config:app:set files_lock lock_timeout --value=1440
This bounds the damage but does not fix the leak: the lock is still orphaned, and the file stays unsyncable until the job runs.
Possible second issue, in files_lock
Even with a finite lock_timeout, expiry does not track activity. LocksRequest::update() — the "extending existing lock" path — writes token, ttl, user_id, owner and scope, but not creation, while LocksRequest::getLocksOlderThan() filters on creation. A lock actively extended by an ongoing session can therefore be purged based on its original creation time, so a long editing session may lose its lock mid-edit. This is why we chose a deliberately large timeout above.
Happy to split this into a separate issue against files_lock if you prefer.
Server details:
- Nextcloud version: 34.0.3 (also observed on 32.x and 33.x before upgrading)
- PHP Version: 8.4
- Database: PostgreSQL 17.10 and MariaDB 11.8.6 — two separate instances, both affected
- files_lock: 34.0.1
Client details:
- OS: Debian (server), Linux desktop
- Desktop sync client: 33.0.7
- Browser: Firefox
- Ngôn ngữ chính
- JavaScript
- Star
- 665
- Fork
- 133
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 172
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/text
-
0. Needs triage bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
nextcloud/text#9482 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
0. Needs triage bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
folder description not shows when using folder tree to navigateCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug feature: folder description
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
1. to develop design call discuss discussion ux
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
nextcloud/text#9334 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của nextcloud/text
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
feimacode/open-design-agent-kit#66 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
xojs/eslint-config-xo#134 ·
-
FEATURE REQUEST
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
linuxmint/cinnamon-spices-extensions#1193 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
huggingface/transformers.js#1839 ·
Maintainer thường phản hồi trong vòng 1 ngày