Repository navigation
Commit 8a2d260
committed
JSCBC-1522: Close and destroy transactions objects off the JS thread
Changes
-------
* Run the core's transactions close() from Transactions::jsClose on a
detached thread and call back through a CallCookie, so removing the
client record from each bucket no longer blocks the event loop;
close inline, as before, when no thread can be started
* Instance now owns every core transactions object created on its
connection; the Transactions and Transaction wrappers hold aliasing
pointers that keep the instance alive instead, so collecting a
Transactions wrapper never frees an object a live transaction still
uses, and no finalizer runs the core's destructor on the JS thread
* Close each object through Instance::closeTransactions, which holds a
lock for the whole close, so an explicit close and the connection's
shutdown are serialized and close it once (two concurrent closes end
the process)
* Instance::shutdown closes every transactions object still open
before the cluster, and destroys them while the cluster is open, or
once the IO thread has stopped when an operation is still in flight
and so still uses its object
* Count a transaction operation from its start until its callback is
invoked or its handler is destroyed, through a TransactionOp shared
by every copy of its RefCallCookie
* Document on Transactions.run that an operation in flight at a worker
terminate or process exit is cancelled, and lost transaction cleanup
decides the outcome
* Add a vars option to expectProcessExits for passing extra
environment variables to an exit fixture
* Add tests that the close callback runs after the call returns, that
two concurrent closes both resolve, and that terminating a worker
while its cluster is closing still exits
* Add a test that commits after the Transactions wrapper that started
the transaction has been collected
* Add a test that terminates workers with transactions still open, and
after collecting their connection, and checks that each client is
removed from the client record
* Add test/suites/transactions/teardownstall.test.ts, which stalls a
worker's IO thread, with a commit queued behind the stall and with
its transactions closed, and checks each terminate returns at its
bound
Change-Id: I2c7d8a4deb1098d805f1b7e902177ad70b747add
Reviewed-on: https://review.couchbase.org/c/couchnode/+/256439
Reviewed-by: Mateusz <matt.wozakowski@couchbase.com>
Tested-by: Jared Casey <jared.casey@couchbase.com>1 parent 7f7480a commit 8a2d260
24 files changed
Lines changed: 1371 additions & 32 deletions
File tree
- lib
- src
- test
- infra
- suites/transactions
- exitfixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1271 | 1271 | | |
1272 | 1272 | | |
1273 | 1273 | | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
1274 | 1280 | | |
1275 | 1281 | | |
1276 | 1282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
136 | 141 | | |
137 | 142 | | |
138 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
8 | 29 | | |
9 | 30 | | |
| 31 | + | |
10 | 32 | | |
11 | 33 | | |
12 | 34 | | |
| |||
25 | 47 | | |
26 | 48 | | |
27 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
28 | 102 | | |
29 | 103 | | |
30 | 104 | | |
| |||
34 | 108 | | |
35 | 109 | | |
36 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
37 | 119 | | |
38 | 120 | | |
39 | 121 | | |
40 | 122 | | |
41 | 123 | | |
| 124 | + | |
42 | 125 | | |
43 | 126 | | |
44 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
9 | 18 | | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
13 | 45 | | |
14 | 46 | | |
15 | 47 | | |
| |||
19 | 51 | | |
20 | 52 | | |
21 | 53 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
27 | 82 | | |
28 | 83 | | |
29 | 84 | | |
30 | 85 | | |
31 | 86 | | |
32 | 87 | | |
33 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
34 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
35 | 102 | | |
36 | 103 | | |
37 | 104 | | |
0 commit comments