File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed
Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ void main() async {
6565 // 1. Atomic persistence (all updates are either applied or rolled back).
6666 // 2. Improved throughput.
6767 await db.writeTransaction((tx) async {
68- await db .execute('INSERT INTO test_data(data) values(?)', ['Test3']);
69- await db .execute('INSERT INTO test_data(data) values(?)', ['Test4']);
68+ await tx .execute('INSERT INTO test_data(data) values(?)', ['Test3']);
69+ await tx .execute('INSERT INTO test_data(data) values(?)', ['Test4']);
7070 });
7171
7272 await db.close();
Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ void main() async {
2929 // 1. Atomic persistence (all updates are either applied or rolled back).
3030 // 2. Improved throughput.
3131 await db.writeTransaction ((tx) async {
32- await db .execute ('INSERT INTO test_data(data) values(?)' , ['Test3' ]);
33- await db .execute ('INSERT INTO test_data(data) values(?)' , ['Test4' ]);
32+ await tx .execute ('INSERT INTO test_data(data) values(?)' , ['Test3' ]);
33+ await tx .execute ('INSERT INTO test_data(data) values(?)' , ['Test4' ]);
3434 });
3535
3636 // Close database to release resources
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ void main() {
175175 // Note: In highly concurrent cases, it could exhaust the connection pool and cause a deadlock.
176176
177177 await db.writeTransaction ((tx) async {
178+ // Use the parent zone to avoid the "recursive lock" error.
178179 await zone.fork ().run (() async {
179180 await db.getAll ('SELECT * FROM test_data' );
180181 });
@@ -192,7 +193,7 @@ void main() {
192193 });
193194 });
194195
195- // This would deadlock, since it shares a global write lock.
196+ // Note: This would deadlock, since it shares a global write lock.
196197 // await db.writeTransaction((tx) async {
197198 // await zone.fork().run(() async {
198199 // await db.execute('SELECT * FROM test_data');
You can’t perform that action at this time.
0 commit comments