File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,12 @@ class SqliteConnectionPool with SqliteQueries implements SqliteConnection {
183183 @override
184184 Future <void > close () async {
185185 closed = true ;
186- for (var connection in _readConnections) {
186+
187+ // It is possible that `readLock()` removes connections from the pool while we're
188+ // closing connections, but not possible for new connections to be added.
189+ // Create a copy of the list, to avoid this triggering "Concurrent modification during iteration"
190+ final toClose = _readConnections.sublist (0 );
191+ for (var connection in toClose) {
187192 await connection.close ();
188193 }
189194 // Closing the write connection cleans up the journal files (-shm and -wal files).
Original file line number Diff line number Diff line change @@ -383,7 +383,6 @@ void main() {
383383 // Second connection to sleep more than first connection
384384 'SELECT test_sleep(test_connection_number() * 10)'
385385 ]));
386- await createTables (db);
387386
388387 final future1 = db.get ('SELECT test_sleep(10) as sleep' );
389388 final future2 = db.get ('SELECT test_sleep(10) as sleep' );
You can’t perform that action at this time.
0 commit comments