Commit a2fc047
committed
Synchronize access to Connection, Statement and ResultSet
This change adds synchronization between accessing and deleting
underlying native objects for `Connection`, `Statement` and
`ResultSet`. All synchronization is done in JNI part, Java-level
synchronization is removed from a few places where it was used.
`volatile` fields are added when checking whether the object is closed
or not.
`Connection`'s underlying native object maintains a list of `Statement`s
currently open on this `Connection`. These statements are closed when
the connection is closed. Running queries are cancelled (interrupted)
automatically when the `Connection` is closed.
Note: `Statement.close()` is blocked if a long query, that was started
from this statement, is still running. `Statement.cancel()` must be
called manually before calling `close()` to perform the closing
promptly. This cannot be done automatically, because `cancel()` is
implemented in the engine as a `Connection`-level operation, thus
calling `cancel()` on a `Statement` can interrupt the query running
on another `Statement` on the same `Connection`.
Synchronization for `Appender` is going to be added in a separate PR.
Testing: new tests added for various sequential and concurrent closure
scenarios.
Fixes: duckdb#1011 parent 6fc1ea6 commit a2fc047
File tree
18 files changed
+1176
-266
lines changed- src
- jni
- main/java/org/duckdb
- test/java/org/duckdb
- test
18 files changed
+1176
-266
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
| 441 | + | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
555 | | - | |
| 555 | + | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| 562 | + | |
562 | 563 | | |
563 | 564 | | |
564 | 565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
0 commit comments