fix(redis): explorer views share one socket, so SELECT + command is not atomic; folder delete can hit another DB
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
DELfrees 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:
_keysis not updated and the error hides the partial delete.
Fix
- Make "select DB + command(s)" atomic: either one socket per
(connectionId, role, db)(noSELECTswitching at all), or a per-socket async lock withrunInDb(db, () async {...})that issuesSELECTinside the lock. One socket per DB is the simpler model; the CLI then gets its own socket andSELECTthere only moves the CLI. delMany:UNLINKwith fallback toDELonERR 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
UNLINKtoRedisConnectionTestFake(redis_connection.dart:817). - Tests: interleaved
SELECTfrom a second user of the socket duringdelMany; CLISELECT 3followed by an editor action.
- 主要言語
- Dart
- スター
- 23
- フォーク
- 1
- 平均マージ
- 31分
- マージ済み PR(30日)
- 570
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
QueryaHub/Querya-Desktop のほかの issue
-
enhancement ui
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
QueryaHub/Querya-Desktop#1689 ·
メンテナーはふだん 1 日以内に返信
-
ui(dialogs): make destructive query and DML preview dialogs adaptive and prevent table name overflowオープンbug frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
QueryaHub/Querya-Desktop#1642 ·
メンテナーはふだん 1 日以内に返信
-
bug error-handling settings
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
QueryaHub/Querya-Desktop#1637 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
QueryaHub/Querya-Desktop#1636 ·
メンテナーはふだん 1 日以内に返信
-
enhancement marketplace
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
QueryaHub/Querya-Desktop#1635 ·
メンテナーはふだん 1 日以内に返信
QueryaHub/Querya-Desktop の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
AppFlowy-IO/AppFlowy#9075 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
avdept/JellyBoxPlayer#375 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
basictech01/uniun#300 ·
メンテナーはふだん 1 日以内に返信
-
Listener that removes itself in its callback causes other listeners to miss updates対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
RevenueCat/purchases-flutter#1962 ·
メンテナーはふだん 1 日以内に返信