mdbxmou 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/.github/workflows/ci.yml +32 -0
  2. package/.github/workflows/publish.yml +27 -0
  3. package/.gitmodules +3 -0
  4. package/CMakeLists.txt +53 -0
  5. package/LICENSE +201 -0
  6. package/README.md +639 -0
  7. package/build.js +11 -0
  8. package/deps/libmdbx/.clang-format +3 -0
  9. package/deps/libmdbx/.cmake-format.yaml +3 -0
  10. package/deps/libmdbx/.le.ini +40 -0
  11. package/deps/libmdbx/CMakeLists.txt +1269 -0
  12. package/deps/libmdbx/COPYRIGHT +159 -0
  13. package/deps/libmdbx/ChangeLog.md +2786 -0
  14. package/deps/libmdbx/GNUmakefile +950 -0
  15. package/deps/libmdbx/LICENSE +177 -0
  16. package/deps/libmdbx/Makefile +16 -0
  17. package/deps/libmdbx/NOTICE +39 -0
  18. package/deps/libmdbx/README.md +863 -0
  19. package/deps/libmdbx/TODO.md +43 -0
  20. package/deps/libmdbx/cmake/compiler.cmake +1221 -0
  21. package/deps/libmdbx/cmake/profile.cmake +58 -0
  22. package/deps/libmdbx/cmake/utils.cmake +524 -0
  23. package/deps/libmdbx/conanfile.py +323 -0
  24. package/deps/libmdbx/docs/Doxyfile.in +2734 -0
  25. package/deps/libmdbx/docs/_preface.md +47 -0
  26. package/deps/libmdbx/docs/_restrictions.md +248 -0
  27. package/deps/libmdbx/docs/_starting.md +245 -0
  28. package/deps/libmdbx/docs/_toc.md +34 -0
  29. package/deps/libmdbx/docs/header.html +96 -0
  30. package/deps/libmdbx/example/CMakeLists.txt +6 -0
  31. package/deps/libmdbx/example/README.md +1 -0
  32. package/deps/libmdbx/example/example-mdbx.c +154 -0
  33. package/deps/libmdbx/example/sample-bdb.txt +77 -0
  34. package/deps/libmdbx/mdbx.h +6655 -0
  35. package/deps/libmdbx/mdbx.h++ +6428 -0
  36. package/deps/libmdbx/packages/buildroot/0001-package-libmdbx-new-package-library-database.patch +173 -0
  37. package/deps/libmdbx/src/alloy.c +54 -0
  38. package/deps/libmdbx/src/api-cold.c +543 -0
  39. package/deps/libmdbx/src/api-copy.c +912 -0
  40. package/deps/libmdbx/src/api-cursor.c +754 -0
  41. package/deps/libmdbx/src/api-dbi.c +315 -0
  42. package/deps/libmdbx/src/api-env.c +1434 -0
  43. package/deps/libmdbx/src/api-extra.c +165 -0
  44. package/deps/libmdbx/src/api-key-transform.c +197 -0
  45. package/deps/libmdbx/src/api-misc.c +286 -0
  46. package/deps/libmdbx/src/api-opts.c +575 -0
  47. package/deps/libmdbx/src/api-range-estimate.c +365 -0
  48. package/deps/libmdbx/src/api-txn-data.c +454 -0
  49. package/deps/libmdbx/src/api-txn.c +921 -0
  50. package/deps/libmdbx/src/atomics-ops.h +364 -0
  51. package/deps/libmdbx/src/atomics-types.h +97 -0
  52. package/deps/libmdbx/src/audit.c +109 -0
  53. package/deps/libmdbx/src/bits.md +34 -0
  54. package/deps/libmdbx/src/chk.c +1796 -0
  55. package/deps/libmdbx/src/cogs.c +309 -0
  56. package/deps/libmdbx/src/cogs.h +506 -0
  57. package/deps/libmdbx/src/coherency.c +170 -0
  58. package/deps/libmdbx/src/config.h.in +88 -0
  59. package/deps/libmdbx/src/cursor.c +2396 -0
  60. package/deps/libmdbx/src/cursor.h +391 -0
  61. package/deps/libmdbx/src/dbi.c +717 -0
  62. package/deps/libmdbx/src/dbi.h +142 -0
  63. package/deps/libmdbx/src/debug_begin.h +36 -0
  64. package/deps/libmdbx/src/debug_end.h +15 -0
  65. package/deps/libmdbx/src/dpl.c +486 -0
  66. package/deps/libmdbx/src/dpl.h +134 -0
  67. package/deps/libmdbx/src/dxb.c +1335 -0
  68. package/deps/libmdbx/src/env.c +607 -0
  69. package/deps/libmdbx/src/essentials.h +125 -0
  70. package/deps/libmdbx/src/gc-get.c +1345 -0
  71. package/deps/libmdbx/src/gc-put.c +970 -0
  72. package/deps/libmdbx/src/gc.h +40 -0
  73. package/deps/libmdbx/src/global.c +474 -0
  74. package/deps/libmdbx/src/internals.h +585 -0
  75. package/deps/libmdbx/src/layout-dxb.h +288 -0
  76. package/deps/libmdbx/src/layout-lck.h +289 -0
  77. package/deps/libmdbx/src/lck-posix.c +859 -0
  78. package/deps/libmdbx/src/lck-windows.c +607 -0
  79. package/deps/libmdbx/src/lck.c +174 -0
  80. package/deps/libmdbx/src/lck.h +110 -0
  81. package/deps/libmdbx/src/logging_and_debug.c +250 -0
  82. package/deps/libmdbx/src/logging_and_debug.h +159 -0
  83. package/deps/libmdbx/src/man1/mdbx_chk.1 +106 -0
  84. package/deps/libmdbx/src/man1/mdbx_copy.1 +95 -0
  85. package/deps/libmdbx/src/man1/mdbx_drop.1 +48 -0
  86. package/deps/libmdbx/src/man1/mdbx_dump.1 +101 -0
  87. package/deps/libmdbx/src/man1/mdbx_load.1 +105 -0
  88. package/deps/libmdbx/src/man1/mdbx_stat.1 +86 -0
  89. package/deps/libmdbx/src/mdbx.c++ +1837 -0
  90. package/deps/libmdbx/src/meta.c +656 -0
  91. package/deps/libmdbx/src/meta.h +168 -0
  92. package/deps/libmdbx/src/mvcc-readers.c +414 -0
  93. package/deps/libmdbx/src/node.c +365 -0
  94. package/deps/libmdbx/src/node.h +102 -0
  95. package/deps/libmdbx/src/ntdll.def +1246 -0
  96. package/deps/libmdbx/src/options.h +534 -0
  97. package/deps/libmdbx/src/osal.c +3485 -0
  98. package/deps/libmdbx/src/osal.h +587 -0
  99. package/deps/libmdbx/src/page-get.c +483 -0
  100. package/deps/libmdbx/src/page-iov.c +185 -0
  101. package/deps/libmdbx/src/page-iov.h +34 -0
  102. package/deps/libmdbx/src/page-ops.c +744 -0
  103. package/deps/libmdbx/src/page-ops.h +142 -0
  104. package/deps/libmdbx/src/pnl.c +236 -0
  105. package/deps/libmdbx/src/pnl.h +146 -0
  106. package/deps/libmdbx/src/preface.h +990 -0
  107. package/deps/libmdbx/src/proto.h +105 -0
  108. package/deps/libmdbx/src/refund.c +212 -0
  109. package/deps/libmdbx/src/sort.h +484 -0
  110. package/deps/libmdbx/src/spill.c +431 -0
  111. package/deps/libmdbx/src/spill.h +74 -0
  112. package/deps/libmdbx/src/table.c +107 -0
  113. package/deps/libmdbx/src/tls.c +551 -0
  114. package/deps/libmdbx/src/tls.h +43 -0
  115. package/deps/libmdbx/src/tools/chk.c +673 -0
  116. package/deps/libmdbx/src/tools/copy.c +166 -0
  117. package/deps/libmdbx/src/tools/drop.c +199 -0
  118. package/deps/libmdbx/src/tools/dump.c +515 -0
  119. package/deps/libmdbx/src/tools/load.c +831 -0
  120. package/deps/libmdbx/src/tools/stat.c +516 -0
  121. package/deps/libmdbx/src/tools/wingetopt.c +87 -0
  122. package/deps/libmdbx/src/tools/wingetopt.h +30 -0
  123. package/deps/libmdbx/src/tree-ops.c +1554 -0
  124. package/deps/libmdbx/src/tree-search.c +140 -0
  125. package/deps/libmdbx/src/txl.c +99 -0
  126. package/deps/libmdbx/src/txl.h +26 -0
  127. package/deps/libmdbx/src/txn.c +1083 -0
  128. package/deps/libmdbx/src/unaligned.h +205 -0
  129. package/deps/libmdbx/src/utils.c +32 -0
  130. package/deps/libmdbx/src/utils.h +76 -0
  131. package/deps/libmdbx/src/version.c.in +44 -0
  132. package/deps/libmdbx/src/walk.c +290 -0
  133. package/deps/libmdbx/src/walk.h +20 -0
  134. package/deps/libmdbx/src/windows-import.c +152 -0
  135. package/deps/libmdbx/src/windows-import.h +128 -0
  136. package/deps/libmdbx/test/CMakeLists.txt +317 -0
  137. package/deps/libmdbx/test/append.c++ +237 -0
  138. package/deps/libmdbx/test/base.h++ +92 -0
  139. package/deps/libmdbx/test/battery-tmux.sh +64 -0
  140. package/deps/libmdbx/test/cases.c++ +118 -0
  141. package/deps/libmdbx/test/chrono.c++ +134 -0
  142. package/deps/libmdbx/test/chrono.h++ +85 -0
  143. package/deps/libmdbx/test/config.c++ +643 -0
  144. package/deps/libmdbx/test/config.h++ +334 -0
  145. package/deps/libmdbx/test/copy.c++ +62 -0
  146. package/deps/libmdbx/test/dead.c++ +39 -0
  147. package/deps/libmdbx/test/dump-load.sh +40 -0
  148. package/deps/libmdbx/test/extra/crunched_delete.c++ +409 -0
  149. package/deps/libmdbx/test/extra/cursor_closing.c++ +410 -0
  150. package/deps/libmdbx/test/extra/dbi.c++ +229 -0
  151. package/deps/libmdbx/test/extra/doubtless_positioning.c++ +253 -0
  152. package/deps/libmdbx/test/extra/dupfix_addodd.c +94 -0
  153. package/deps/libmdbx/test/extra/dupfix_multiple.c++ +311 -0
  154. package/deps/libmdbx/test/extra/early_close_dbi.c++ +137 -0
  155. package/deps/libmdbx/test/extra/hex_base64_base58.c++ +118 -0
  156. package/deps/libmdbx/test/extra/maindb_ordinal.c++ +61 -0
  157. package/deps/libmdbx/test/extra/open.c++ +96 -0
  158. package/deps/libmdbx/test/extra/pcrf/README.md +2 -0
  159. package/deps/libmdbx/test/extra/pcrf/pcrf_test.c +380 -0
  160. package/deps/libmdbx/test/extra/probe.c++ +10 -0
  161. package/deps/libmdbx/test/extra/txn.c++ +407 -0
  162. package/deps/libmdbx/test/extra/upsert_alldups.c +193 -0
  163. package/deps/libmdbx/test/fork.c++ +263 -0
  164. package/deps/libmdbx/test/hill.c++ +447 -0
  165. package/deps/libmdbx/test/jitter.c++ +197 -0
  166. package/deps/libmdbx/test/keygen.c++ +393 -0
  167. package/deps/libmdbx/test/keygen.h++ +130 -0
  168. package/deps/libmdbx/test/log.c++ +358 -0
  169. package/deps/libmdbx/test/log.h++ +91 -0
  170. package/deps/libmdbx/test/main.c++ +706 -0
  171. package/deps/libmdbx/test/nested.c++ +318 -0
  172. package/deps/libmdbx/test/osal-unix.c++ +647 -0
  173. package/deps/libmdbx/test/osal-windows.c++ +440 -0
  174. package/deps/libmdbx/test/osal.h++ +41 -0
  175. package/deps/libmdbx/test/stochastic.sh +690 -0
  176. package/deps/libmdbx/test/stub/LICENSE +24 -0
  177. package/deps/libmdbx/test/stub/README.md +8 -0
  178. package/deps/libmdbx/test/stub/pthread_barrier.c +104 -0
  179. package/deps/libmdbx/test/stub/pthread_barrier.h +77 -0
  180. package/deps/libmdbx/test/test.c++ +1551 -0
  181. package/deps/libmdbx/test/test.h++ +298 -0
  182. package/deps/libmdbx/test/tmux.conf +3 -0
  183. package/deps/libmdbx/test/try.c++ +30 -0
  184. package/deps/libmdbx/test/ttl.c++ +240 -0
  185. package/deps/libmdbx/test/utils.c++ +203 -0
  186. package/deps/libmdbx/test/utils.h++ +326 -0
  187. package/deps/libmdbx/test/valgrind_suppress.txt +536 -0
  188. package/lib/mdbx_evn_async.js +211 -0
  189. package/lib/mdbx_worker.js +195 -0
  190. package/lib/nativemou.js +6 -0
  191. package/package.json +38 -0
  192. package/src/async/envmou_close.cpp +34 -0
  193. package/src/async/envmou_close.hpp +32 -0
  194. package/src/async/envmou_copy_to.cpp +29 -0
  195. package/src/async/envmou_copy_to.hpp +38 -0
  196. package/src/async/envmou_keys.cpp +201 -0
  197. package/src/async/envmou_keys.hpp +50 -0
  198. package/src/async/envmou_open.cpp +38 -0
  199. package/src/async/envmou_open.hpp +33 -0
  200. package/src/async/envmou_query.cpp +167 -0
  201. package/src/async/envmou_query.hpp +53 -0
  202. package/src/dbimou.cpp +522 -0
  203. package/src/dbimou.hpp +82 -0
  204. package/src/env_arg0.hpp +24 -0
  205. package/src/envmou.cpp +445 -0
  206. package/src/envmou.hpp +116 -0
  207. package/src/modulemou.cpp +113 -0
  208. package/src/querymou.cpp +177 -0
  209. package/src/querymou.hpp +93 -0
  210. package/src/txnmou.cpp +254 -0
  211. package/src/txnmou.hpp +122 -0
  212. package/src/typemou.hpp +239 -0
  213. package/src/valuemou.hpp +194 -0
  214. package/test/async.js +67 -0
  215. package/test/e3.js +38 -0
  216. package/test/e4.js +89 -0
  217. package/test/e5.js +162 -0
  218. package/test/test-batch-ops.js +243 -0
  219. package/test/test-cursor-mode.js +84 -0
  220. package/test/test-multi-mode.js +87 -0
@@ -0,0 +1,536 @@
1
+ {
2
+ msync-whole-mmap-1
3
+ Memcheck:Param
4
+ msync(start)
5
+ ...
6
+ fun:dxb_sync_locked*
7
+ }
8
+ {
9
+ msync-whole-mmap-2
10
+ Memcheck:Param
11
+ msync(start)
12
+ ...
13
+ fun:env_sync*
14
+ }
15
+ {
16
+ msync-whole-mmap-3
17
+ Memcheck:Param
18
+ msync(start)
19
+ ...
20
+ fun:map_resize*
21
+ }
22
+ {
23
+ msync-wipe-steady
24
+ Memcheck:Param
25
+ msync(start)
26
+ ...
27
+ fun:meta_wipe_steady*
28
+ }
29
+ {
30
+ msync-meta
31
+ Memcheck:Param
32
+ msync(start)
33
+ ...
34
+ fun:meta_sync*
35
+ }
36
+ {
37
+ msync-spill
38
+ Memcheck:Param
39
+ msync(start)
40
+ ...
41
+ fun:txn_spill*
42
+ }
43
+
44
+ # memcmp() inside iov_write() as workaround for https://libmdbx.dqdkfa.ru/dead-github/issues/269
45
+ {
46
+ iov-pagecheck-1
47
+ Memcheck:Cond
48
+ fun:bcmp
49
+ fun:iov_callback4dirtypages
50
+ fun:osal_ioring_walk
51
+ fun:iov_complete
52
+ fun:iov_write
53
+ }
54
+ {
55
+ iov-pagecheck-2
56
+ Memcheck:Cond
57
+ fun:memcmp*
58
+ fun:iov_callback4dirtypages
59
+ fun:osal_ioring_walk
60
+ fun:iov_complete
61
+ fun:iov_write
62
+ }
63
+
64
+ # single-page flush by pwrite()
65
+ {
66
+ pwrite-page-flush
67
+ Memcheck:Param
68
+ pwrite(buf)
69
+ ...
70
+ fun:iov_write*
71
+ }
72
+ {
73
+ pwrite64-page-flush
74
+ Memcheck:Param
75
+ pwrite64(buf)
76
+ ...
77
+ fun:iov_write*
78
+ }
79
+
80
+ # modern Valgrind don't support the `vector[...]` pattern
81
+ #{
82
+ # pwritev-page-flush
83
+ # Memcheck:Param
84
+ # pwritev(vector[...])
85
+ # ...
86
+ # fun:iov_write*
87
+ #}
88
+ # for((i=0;i<64;++i)); do echo -e "{\n pwritev-page-flush-$i\n Memcheck:Param\n pwritev(vector[$i])\n ...\n fun:iov_write*\n}"; done >> valgrind_suppress.txt
89
+ {
90
+ pwritev-page-flush-0
91
+ Memcheck:Param
92
+ pwritev(vector[0])
93
+ ...
94
+ fun:iov_write*
95
+ }
96
+ {
97
+ pwritev-page-flush-1
98
+ Memcheck:Param
99
+ pwritev(vector[1])
100
+ ...
101
+ fun:iov_write*
102
+ }
103
+ {
104
+ pwritev-page-flush-2
105
+ Memcheck:Param
106
+ pwritev(vector[2])
107
+ ...
108
+ fun:iov_write*
109
+ }
110
+ {
111
+ pwritev-page-flush-3
112
+ Memcheck:Param
113
+ pwritev(vector[3])
114
+ ...
115
+ fun:iov_write*
116
+ }
117
+ {
118
+ pwritev-page-flush-4
119
+ Memcheck:Param
120
+ pwritev(vector[4])
121
+ ...
122
+ fun:iov_write*
123
+ }
124
+ {
125
+ pwritev-page-flush-5
126
+ Memcheck:Param
127
+ pwritev(vector[5])
128
+ ...
129
+ fun:iov_write*
130
+ }
131
+ {
132
+ pwritev-page-flush-6
133
+ Memcheck:Param
134
+ pwritev(vector[6])
135
+ ...
136
+ fun:iov_write*
137
+ }
138
+ {
139
+ pwritev-page-flush-7
140
+ Memcheck:Param
141
+ pwritev(vector[7])
142
+ ...
143
+ fun:iov_write*
144
+ }
145
+ {
146
+ pwritev-page-flush-8
147
+ Memcheck:Param
148
+ pwritev(vector[8])
149
+ ...
150
+ fun:iov_write*
151
+ }
152
+ {
153
+ pwritev-page-flush-9
154
+ Memcheck:Param
155
+ pwritev(vector[9])
156
+ ...
157
+ fun:iov_write*
158
+ }
159
+ {
160
+ pwritev-page-flush-10
161
+ Memcheck:Param
162
+ pwritev(vector[10])
163
+ ...
164
+ fun:iov_write*
165
+ }
166
+ {
167
+ pwritev-page-flush-11
168
+ Memcheck:Param
169
+ pwritev(vector[11])
170
+ ...
171
+ fun:iov_write*
172
+ }
173
+ {
174
+ pwritev-page-flush-12
175
+ Memcheck:Param
176
+ pwritev(vector[12])
177
+ ...
178
+ fun:iov_write*
179
+ }
180
+ {
181
+ pwritev-page-flush-13
182
+ Memcheck:Param
183
+ pwritev(vector[13])
184
+ ...
185
+ fun:iov_write*
186
+ }
187
+ {
188
+ pwritev-page-flush-14
189
+ Memcheck:Param
190
+ pwritev(vector[14])
191
+ ...
192
+ fun:iov_write*
193
+ }
194
+ {
195
+ pwritev-page-flush-15
196
+ Memcheck:Param
197
+ pwritev(vector[15])
198
+ ...
199
+ fun:iov_write*
200
+ }
201
+ {
202
+ pwritev-page-flush-16
203
+ Memcheck:Param
204
+ pwritev(vector[16])
205
+ ...
206
+ fun:iov_write*
207
+ }
208
+ {
209
+ pwritev-page-flush-17
210
+ Memcheck:Param
211
+ pwritev(vector[17])
212
+ ...
213
+ fun:iov_write*
214
+ }
215
+ {
216
+ pwritev-page-flush-18
217
+ Memcheck:Param
218
+ pwritev(vector[18])
219
+ ...
220
+ fun:iov_write*
221
+ }
222
+ {
223
+ pwritev-page-flush-19
224
+ Memcheck:Param
225
+ pwritev(vector[19])
226
+ ...
227
+ fun:iov_write*
228
+ }
229
+ {
230
+ pwritev-page-flush-20
231
+ Memcheck:Param
232
+ pwritev(vector[20])
233
+ ...
234
+ fun:iov_write*
235
+ }
236
+ {
237
+ pwritev-page-flush-21
238
+ Memcheck:Param
239
+ pwritev(vector[21])
240
+ ...
241
+ fun:iov_write*
242
+ }
243
+ {
244
+ pwritev-page-flush-22
245
+ Memcheck:Param
246
+ pwritev(vector[22])
247
+ ...
248
+ fun:iov_write*
249
+ }
250
+ {
251
+ pwritev-page-flush-23
252
+ Memcheck:Param
253
+ pwritev(vector[23])
254
+ ...
255
+ fun:iov_write*
256
+ }
257
+ {
258
+ pwritev-page-flush-24
259
+ Memcheck:Param
260
+ pwritev(vector[24])
261
+ ...
262
+ fun:iov_write*
263
+ }
264
+ {
265
+ pwritev-page-flush-25
266
+ Memcheck:Param
267
+ pwritev(vector[25])
268
+ ...
269
+ fun:iov_write*
270
+ }
271
+ {
272
+ pwritev-page-flush-26
273
+ Memcheck:Param
274
+ pwritev(vector[26])
275
+ ...
276
+ fun:iov_write*
277
+ }
278
+ {
279
+ pwritev-page-flush-27
280
+ Memcheck:Param
281
+ pwritev(vector[27])
282
+ ...
283
+ fun:iov_write*
284
+ }
285
+ {
286
+ pwritev-page-flush-28
287
+ Memcheck:Param
288
+ pwritev(vector[28])
289
+ ...
290
+ fun:iov_write*
291
+ }
292
+ {
293
+ pwritev-page-flush-29
294
+ Memcheck:Param
295
+ pwritev(vector[29])
296
+ ...
297
+ fun:iov_write*
298
+ }
299
+ {
300
+ pwritev-page-flush-30
301
+ Memcheck:Param
302
+ pwritev(vector[30])
303
+ ...
304
+ fun:iov_write*
305
+ }
306
+ {
307
+ pwritev-page-flush-31
308
+ Memcheck:Param
309
+ pwritev(vector[31])
310
+ ...
311
+ fun:iov_write*
312
+ }
313
+ {
314
+ pwritev-page-flush-32
315
+ Memcheck:Param
316
+ pwritev(vector[32])
317
+ ...
318
+ fun:iov_write*
319
+ }
320
+ {
321
+ pwritev-page-flush-33
322
+ Memcheck:Param
323
+ pwritev(vector[33])
324
+ ...
325
+ fun:iov_write*
326
+ }
327
+ {
328
+ pwritev-page-flush-34
329
+ Memcheck:Param
330
+ pwritev(vector[34])
331
+ ...
332
+ fun:iov_write*
333
+ }
334
+ {
335
+ pwritev-page-flush-35
336
+ Memcheck:Param
337
+ pwritev(vector[35])
338
+ ...
339
+ fun:iov_write*
340
+ }
341
+ {
342
+ pwritev-page-flush-36
343
+ Memcheck:Param
344
+ pwritev(vector[36])
345
+ ...
346
+ fun:iov_write*
347
+ }
348
+ {
349
+ pwritev-page-flush-37
350
+ Memcheck:Param
351
+ pwritev(vector[37])
352
+ ...
353
+ fun:iov_write*
354
+ }
355
+ {
356
+ pwritev-page-flush-38
357
+ Memcheck:Param
358
+ pwritev(vector[38])
359
+ ...
360
+ fun:iov_write*
361
+ }
362
+ {
363
+ pwritev-page-flush-39
364
+ Memcheck:Param
365
+ pwritev(vector[39])
366
+ ...
367
+ fun:iov_write*
368
+ }
369
+ {
370
+ pwritev-page-flush-40
371
+ Memcheck:Param
372
+ pwritev(vector[40])
373
+ ...
374
+ fun:iov_write*
375
+ }
376
+ {
377
+ pwritev-page-flush-41
378
+ Memcheck:Param
379
+ pwritev(vector[41])
380
+ ...
381
+ fun:iov_write*
382
+ }
383
+ {
384
+ pwritev-page-flush-42
385
+ Memcheck:Param
386
+ pwritev(vector[42])
387
+ ...
388
+ fun:iov_write*
389
+ }
390
+ {
391
+ pwritev-page-flush-43
392
+ Memcheck:Param
393
+ pwritev(vector[43])
394
+ ...
395
+ fun:iov_write*
396
+ }
397
+ {
398
+ pwritev-page-flush-44
399
+ Memcheck:Param
400
+ pwritev(vector[44])
401
+ ...
402
+ fun:iov_write*
403
+ }
404
+ {
405
+ pwritev-page-flush-45
406
+ Memcheck:Param
407
+ pwritev(vector[45])
408
+ ...
409
+ fun:iov_write*
410
+ }
411
+ {
412
+ pwritev-page-flush-46
413
+ Memcheck:Param
414
+ pwritev(vector[46])
415
+ ...
416
+ fun:iov_write*
417
+ }
418
+ {
419
+ pwritev-page-flush-47
420
+ Memcheck:Param
421
+ pwritev(vector[47])
422
+ ...
423
+ fun:iov_write*
424
+ }
425
+ {
426
+ pwritev-page-flush-48
427
+ Memcheck:Param
428
+ pwritev(vector[48])
429
+ ...
430
+ fun:iov_write*
431
+ }
432
+ {
433
+ pwritev-page-flush-49
434
+ Memcheck:Param
435
+ pwritev(vector[49])
436
+ ...
437
+ fun:iov_write*
438
+ }
439
+ {
440
+ pwritev-page-flush-50
441
+ Memcheck:Param
442
+ pwritev(vector[50])
443
+ ...
444
+ fun:iov_write*
445
+ }
446
+ {
447
+ pwritev-page-flush-51
448
+ Memcheck:Param
449
+ pwritev(vector[51])
450
+ ...
451
+ fun:iov_write*
452
+ }
453
+ {
454
+ pwritev-page-flush-52
455
+ Memcheck:Param
456
+ pwritev(vector[52])
457
+ ...
458
+ fun:iov_write*
459
+ }
460
+ {
461
+ pwritev-page-flush-53
462
+ Memcheck:Param
463
+ pwritev(vector[53])
464
+ ...
465
+ fun:iov_write*
466
+ }
467
+ {
468
+ pwritev-page-flush-54
469
+ Memcheck:Param
470
+ pwritev(vector[54])
471
+ ...
472
+ fun:iov_write*
473
+ }
474
+ {
475
+ pwritev-page-flush-55
476
+ Memcheck:Param
477
+ pwritev(vector[55])
478
+ ...
479
+ fun:iov_write*
480
+ }
481
+ {
482
+ pwritev-page-flush-56
483
+ Memcheck:Param
484
+ pwritev(vector[56])
485
+ ...
486
+ fun:iov_write*
487
+ }
488
+ {
489
+ pwritev-page-flush-57
490
+ Memcheck:Param
491
+ pwritev(vector[57])
492
+ ...
493
+ fun:iov_write*
494
+ }
495
+ {
496
+ pwritev-page-flush-58
497
+ Memcheck:Param
498
+ pwritev(vector[58])
499
+ ...
500
+ fun:iov_write*
501
+ }
502
+ {
503
+ pwritev-page-flush-59
504
+ Memcheck:Param
505
+ pwritev(vector[59])
506
+ ...
507
+ fun:iov_write*
508
+ }
509
+ {
510
+ pwritev-page-flush-60
511
+ Memcheck:Param
512
+ pwritev(vector[60])
513
+ ...
514
+ fun:iov_write*
515
+ }
516
+ {
517
+ pwritev-page-flush-61
518
+ Memcheck:Param
519
+ pwritev(vector[61])
520
+ ...
521
+ fun:iov_write*
522
+ }
523
+ {
524
+ pwritev-page-flush-62
525
+ Memcheck:Param
526
+ pwritev(vector[62])
527
+ ...
528
+ fun:iov_write*
529
+ }
530
+ {
531
+ pwritev-page-flush-63
532
+ Memcheck:Param
533
+ pwritev(vector[63])
534
+ ...
535
+ fun:iov_write*
536
+ }
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ const { Worker } = require("worker_threads");
3
+ const workerFile = require.resolve("./mdbx_worker.js");
4
+ let nextReqId = 1;
5
+ let nextTxnId = 1;
6
+ let nextDbiId = 1;
7
+
8
+ class MDBX_Async_Env {
9
+ constructor() {
10
+ this.worker = null;
11
+ // Ожидающие запросы: id -> { resolve, reject }
12
+ this.pending = new Map();
13
+ this.envOpened = false;
14
+ }
15
+
16
+ _createWorker() {
17
+ const w = new Worker(workerFile);
18
+
19
+ // Обработка ответов
20
+ w.on("message", (m) => {
21
+ const p = this.pending.get(m.id);
22
+ if (!p) return; // неизвестный или уже очищенный
23
+ this.pending.delete(m.id);
24
+ if (m.ok) {
25
+ p.resolve(m.result);
26
+ } else {
27
+ p.reject(new Error(m.error));
28
+ }
29
+ });
30
+
31
+ // Обработка ошибок воркера
32
+ w.on("error", (e) => {
33
+ for (const [id, p] of this.pending) {
34
+ p.reject(e);
35
+ this.pending.delete(id);
36
+ }
37
+ });
38
+
39
+ // При выходе воркера
40
+ w.on("exit", (code) => {
41
+ if (code !== 0) {
42
+ const err = new Error(`worker exited with code ${code}`);
43
+ for (const [id, p] of this.pending) {
44
+ p.reject(err);
45
+ this.pending.delete(id);
46
+ }
47
+ }
48
+ });
49
+
50
+ return w;
51
+ }
52
+
53
+ _dispatch(cmd, params) {
54
+ const id = nextReqId++;
55
+ return new Promise((resolve, reject) => {
56
+ this.pending.set(id, { resolve, reject });
57
+ try {
58
+ this.worker.postMessage({ id, cmd, params });
59
+ } catch (e) {
60
+ // Если отправка упала синхронно, чистим
61
+ if (this.pending.get(id)) this.pending.delete(id);
62
+ reject(e);
63
+ }
64
+ });
65
+ }
66
+
67
+ async open(opts) {
68
+ if (this.envOpened) throw new Error("env already open");
69
+ if (!this.worker) {
70
+ this.worker = this._createWorker();
71
+ }
72
+ await this._dispatch("env_open", opts);
73
+ this.envOpened = true;
74
+ }
75
+
76
+ async close() {
77
+ if (!this.envOpened) return;
78
+ await this._dispatch("env_close");
79
+ this.envOpened = false;
80
+ }
81
+
82
+ async terminate() {
83
+ // Сначала закрываем env если открыт
84
+ if (this.envOpened) {
85
+ await this.close();
86
+ }
87
+
88
+ // Отменяем все ожидающие запросы
89
+ const cancelError = new Error("Environment terminated");
90
+ for (const [id, p] of this.pending) {
91
+ p.reject(cancelError);
92
+ }
93
+ this.pending.clear();
94
+
95
+ // Завершаем worker
96
+ if (this.worker) {
97
+ await this.worker.terminate();
98
+ this.worker = null;
99
+ }
100
+ }
101
+
102
+ async startWrite() {
103
+ if (!this.worker) throw new Error("Environment not opened");
104
+ const txnId = nextTxnId++;
105
+ await this._dispatch("txn_begin", { txnId, mode: "write" });
106
+ return new Txn_Proxy(this, txnId, true);
107
+ }
108
+
109
+ async startRead() {
110
+ if (!this.worker) throw new Error("Environment not opened");
111
+ const txnId = nextTxnId++;
112
+ await this._dispatch("txn_begin", { txnId, mode: "read" });
113
+ return new Txn_Proxy(this, txnId, false);
114
+ }
115
+ }
116
+
117
+ class Txn_Proxy {
118
+ constructor(env, txnId, write) {
119
+ this._env = env;
120
+ this._txnId = txnId;
121
+ this._write = write;
122
+ this._closed = false;
123
+ }
124
+
125
+ _call(cmd, params) {
126
+ if (this._closed) return Promise.reject(new Error("txn closed"));
127
+ return this._env._dispatch(cmd, { txnId: this._txnId, ...params });
128
+ }
129
+
130
+ async openMap(opts = {}) {
131
+ // opts: { name, keyMode, valMode, flags, create }
132
+ const dbiId = nextDbiId++;
133
+ const result = await this._call("map_open", {
134
+ dbiId,
135
+ name: opts.name || null,
136
+ keyMode: opts.keyMode ?? 0,
137
+ valMode: opts.valMode ?? 0,
138
+ flags: opts.flags ?? 0,
139
+ create: !!opts.create
140
+ });
141
+ return new Dbi_Proxy(this, dbiId, result.meta);
142
+ }
143
+
144
+ put(...args) { throw new Error("Use dbi.put()"); }
145
+
146
+ async commit() {
147
+ if (this._closed) return;
148
+ await this._call("txn_commit");
149
+ this._closed = true;
150
+ }
151
+
152
+ async abort() {
153
+ if (this._closed) return;
154
+ await this._call("txn_abort");
155
+ this._closed = true;
156
+ }
157
+ }
158
+
159
+ class Dbi_Proxy {
160
+ constructor(tx, dbiId, meta) {
161
+ this._tx = tx;
162
+ this._dbiId = dbiId;
163
+ this.meta = meta;
164
+ }
165
+
166
+ _call(cmd, params) {
167
+ return this._tx._call(cmd, { dbiId: this._dbiId, ...params });
168
+ }
169
+
170
+ put(key, value, flags = 0) {
171
+ return this._call("dbi_put", { key, value, flags });
172
+ }
173
+
174
+ get(key) {
175
+ return this._call("dbi_get", { key });
176
+ }
177
+
178
+ del(key) {
179
+ return this._call("dbi_del", { key });
180
+ }
181
+
182
+ stat() {
183
+ return this._call("dbi_stat", {});
184
+ }
185
+
186
+ forEach(cb) {
187
+ // Потоково: worker возвращает батчи
188
+ return this._call("dbi_iter_all", {}).then(arr => {
189
+ arr.forEach((kv, i) => cb(kv.key, kv.value, i));
190
+ });
191
+ }
192
+
193
+ // Групповые операции
194
+ getBatch(keys) {
195
+ // Читаем множество ключей одной командой
196
+ return this._call("dbi_get_batch", { keys });
197
+ }
198
+
199
+ putBatch(items, flags = 0) {
200
+ // Записываем множество пар ключ-значение одной командой
201
+ // items: [{ key, value }, ...]
202
+ return this._call("dbi_put_batch", { items, flags });
203
+ }
204
+
205
+ delBatch(keys) {
206
+ // Удаляем множество ключей одной командой
207
+ return this._call("dbi_del_batch", { keys });
208
+ }
209
+ }
210
+
211
+ module.exports = { MDBX_Async_Env };