Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

fix(redis): explorer views share one socket, so SELECT + command is not atomic; folder delete can hit another DB

Đang mở
#1,569 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
35/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ệ
dart, redis
Lĩnh vực
backend, database

Hướng nghiên cứu

Start with lib/core/database/redis_service.dart and lib/core/database/redis_connection.dart to trace socket sharing and database selection, then read lib/features/redis/redis_keys_view.dart and redis_cli_workspace.dart for the affected operations. Reproduce the interleaving described in the issue and inspect the existing Redis connection tests. Done means database selection and commands cannot interfere across views or the CLI, with regression coverage for both reported cases.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

backend bug connections P1 stability

Problem

RedisService.acquire keys sockets by connectionId::role (lib/core/database/redis_service.dart:26). Every Redis explorer for a connection, for any database index, uses the same explorer socket. Views select the database with a separate command before working:

await widget.connection.selectDatabase(widget.database); // SELECT n
await widget.connection.delMany(keys);                    // DEL ... (several round trips)

SELECT is socket state, and the pair is not atomic. Anything else that runs on the socket between the two awaits changes the database the next command hits.

1. Folder delete can delete keys in another database (data loss)

RedisKeysView._deleteFolder (lib/features/redis/redis_keys_view.dart:218-225) selects the DB once, then delMany (lib/core/database/redis_connection.dart:749-761) sends sequential DEL chunks of 200, awaiting each.

Steps: open db0, load a folder with more than 200 keys, Delete folder, then while it runs click db3 in the tree. The workspace replaces the explorer (ValueKey('redis_<id>_db_3'), workspace_panel.dart:363). The old view is disposed but its delMany loop keeps going (no cancellation). The new view sends SELECT 3 + SCAN on the same socket, and the remaining DEL chunks run in db3, deleting any keys there with the same names.

2. The CLI runs commands in a database other than the one it shows

RedisCliWorkspace tracks _currentDb only when the user types SELECT (redis_cli_workspace.dart:487-490) and sends every other command as is (:512). The key editor and keys view in the same explorer re-select widget.database before each operation. After SELECT 3 in the CLI, opening any key moves the socket back to db0. The CLI prompt still says db3, but the next DEL / FLUSHDB runs in db0.

3. delMany itself
  • DEL frees large values synchronously and blocks the Redis event loop. UNLINK (Redis >= 4.0) is not used anywhere in the codebase.
  • Chunks are sent one after another although the class already pipelines in typesAndTtls.
  • On a failure midway the UI does not know which keys are gone: _keys is not updated and the error hides the partial delete.

Fix

  • Make "select DB + command(s)" atomic: either one socket per (connectionId, role, db) (no SELECT switching at all), or a per-socket async lock with runInDb(db, () async {...}) that issues SELECT inside the lock. One socket per DB is the simpler model; the CLI then gets its own socket and SELECT there only moves the CLI.
  • delMany: UNLINK with fallback to DEL on ERR unknown command, pipeline the chunks, stop when the owner is disposed (cancel token), return the count/keys actually removed and reload the list on partial failure.
  • Add UNLINK to RedisConnectionTestFake (redis_connection.dart:817).
  • Tests: interleaved SELECT from a second user of the socket during delMany; CLI SELECT 3 followed by an editor action.
Ngôn ngữ chính
Dart
Star
23
Fork
1
Merge trung bình
31 phút
Pull request đã merge (30 ngày)
570

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của QueryaHub/Querya-Desktop

Tất cả issue của QueryaHub/Querya-Desktop

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.