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 {
183
183
@override
184
184
Future <void > close () async {
185
185
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) {
187
192
await connection.close ();
188
193
}
189
194
// 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() {
383
383
// Second connection to sleep more than first connection
384
384
'SELECT test_sleep(test_connection_number() * 10)'
385
385
]));
386
- await createTables (db);
387
386
388
387
final future1 = db.get ('SELECT test_sleep(10) as sleep' );
389
388
final future2 = db.get ('SELECT test_sleep(10) as sleep' );
You can’t perform that action at this time.
0 commit comments