couchbase 4.2.1 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/CMakeLists.txt +1 -0
  2. package/deps/couchbase-cxx-client/.gitmodules +3 -0
  3. package/deps/couchbase-cxx-client/.idea/misc.xml +1 -0
  4. package/deps/couchbase-cxx-client/.idea/vcs.xml +1 -0
  5. package/deps/couchbase-cxx-client/CMakeLists.txt +11 -1
  6. package/deps/couchbase-cxx-client/README.md +3 -3
  7. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +4 -1
  8. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +13 -1
  9. package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
  10. package/deps/couchbase-cxx-client/core/cluster.hxx +15 -5
  11. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +17 -6
  12. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -1
  13. package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +93 -0
  14. package/deps/couchbase-cxx-client/core/impl/configuration_profiles_registry.cxx +11 -0
  15. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +119 -0
  16. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +108 -0
  17. package/deps/couchbase-cxx-client/core/impl/get.cxx +1 -1
  18. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +76 -0
  19. package/deps/couchbase-cxx-client/core/impl/query.cxx +5 -7
  20. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +168 -0
  21. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +15 -1
  22. package/deps/couchbase-cxx-client/core/logger/configuration.hxx +3 -0
  23. package/deps/couchbase-cxx-client/core/logger/level.hxx +21 -0
  24. package/deps/couchbase-cxx-client/core/logger/logger.hxx +4 -6
  25. package/deps/couchbase-cxx-client/core/meta/CMakeLists.txt +4 -2
  26. package/deps/couchbase-cxx-client/core/meta/features.hxx +31 -0
  27. package/deps/couchbase-cxx-client/core/meta/version.cxx +67 -5
  28. package/deps/couchbase-cxx-client/core/meta/version.hxx +12 -1
  29. package/deps/couchbase-cxx-client/core/metrics/CMakeLists.txt +4 -1
  30. package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +46 -5
  31. package/deps/couchbase-cxx-client/core/metrics/logging_meter.hxx +10 -26
  32. package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -2
  33. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +10 -12
  34. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -3
  35. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.cxx +8 -14
  36. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -1
  37. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +15 -8
  38. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +7 -14
  39. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
  40. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +11 -16
  41. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
  42. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.cxx +8 -12
  43. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
  44. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.cxx +21 -12
  45. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -2
  46. package/deps/couchbase-cxx-client/core/origin.hxx +1 -1
  47. package/deps/couchbase-cxx-client/core/platform/uuid.cc +1 -2
  48. package/deps/couchbase-cxx-client/core/protocol/cmd_hello.hxx +5 -1
  49. package/deps/couchbase-cxx-client/core/query_context.hxx +79 -0
  50. package/deps/couchbase-cxx-client/core/tracing/CMakeLists.txt +3 -1
  51. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +19 -4
  52. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.hxx +2 -2
  53. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +10 -4
  54. package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +52 -63
  55. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +8 -3
  56. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +163 -126
  57. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +24 -37
  58. package/deps/couchbase-cxx-client/core/transactions/forward_compat.hxx +4 -4
  59. package/deps/couchbase-cxx-client/core/transactions/internal/atr_cleanup_entry.hxx +51 -13
  60. package/deps/couchbase-cxx-client/core/transactions/internal/client_record.hxx +26 -1
  61. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.hxx +21 -0
  62. package/deps/couchbase-cxx-client/core/transactions/internal/logging.hxx +40 -18
  63. package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +5 -0
  64. package/deps/couchbase-cxx-client/core/transactions/result.hxx +26 -0
  65. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +48 -47
  66. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +6 -6
  67. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +33 -19
  68. package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +18 -2
  69. package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +25 -2
  70. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +4 -4
  71. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +49 -56
  72. package/deps/couchbase-cxx-client/core/transactions/waitable_op_list.hxx +7 -7
  73. package/deps/couchbase-cxx-client/core/transactions.hxx +0 -12
  74. package/deps/couchbase-cxx-client/core/utils/binary.hxx +1 -1
  75. package/deps/couchbase-cxx-client/core/utils/keyspace.hxx +55 -0
  76. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +12 -45
  77. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +1 -1
  78. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +6 -7
  79. package/deps/couchbase-cxx-client/couchbase/collection.hxx +8 -0
  80. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +218 -0
  81. package/deps/couchbase-cxx-client/couchbase/configuration_profiles_registry.hxx +3 -0
  82. package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +166 -0
  83. package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +172 -0
  84. package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +129 -0
  85. package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +116 -0
  86. package/deps/couchbase-cxx-client/couchbase/fmt/cas.hxx +1 -1
  87. package/deps/couchbase-cxx-client/couchbase/fmt/query_scan_consistency.hxx +46 -0
  88. package/deps/couchbase-cxx-client/couchbase/fmt/query_status.hxx +70 -0
  89. package/deps/couchbase-cxx-client/couchbase/fmt/tls_verify_mode.hxx +46 -0
  90. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +100 -0
  91. package/deps/couchbase-cxx-client/{core → couchbase}/management/query_index.hxx +2 -2
  92. package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +16 -0
  93. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +178 -6
  94. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +1 -18
  95. package/deps/couchbase-cxx-client/couchbase/scope.hxx +5 -2
  96. package/deps/couchbase-cxx-client/couchbase/tracing/request_tracer.hxx +16 -0
  97. package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +11 -4
  98. package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +5 -3
  99. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_keyspace.hxx +16 -0
  100. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +0 -6
  101. package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +115 -0
  102. package/deps/couchbase-cxx-client/examples/minimal.cxx +3 -1
  103. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +72 -0
  104. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +727 -310
  105. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +4 -8
  106. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +14 -0
  107. package/deps/couchbase-cxx-client/test/test_transaction_transaction_public_blocking_api.cxx +34 -19
  108. package/deps/couchbase-cxx-client/test/test_unit_transaction_logging.cxx +66 -22
  109. package/deps/couchbase-cxx-client/test/test_unit_utils.cxx +51 -0
  110. package/deps/couchbase-cxx-client/test/tools/tool_kv_loader.cxx +2 -2
  111. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -0
  112. package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +4 -4
  113. package/deps/couchbase-cxx-client/third_party/docopt/.travis.yml +103 -0
  114. package/deps/couchbase-cxx-client/third_party/docopt/CMakeLists.txt +129 -0
  115. package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-Boost-1.0 +23 -0
  116. package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-MIT +23 -0
  117. package/deps/couchbase-cxx-client/third_party/docopt/README.rst +479 -0
  118. package/deps/couchbase-cxx-client/third_party/docopt/docopt-config.cmake +1 -0
  119. package/deps/couchbase-cxx-client/third_party/docopt/docopt.cpp +687 -0
  120. package/deps/couchbase-cxx-client/third_party/docopt/docopt.h +98 -0
  121. package/deps/couchbase-cxx-client/third_party/docopt/docopt.pc.in +9 -0
  122. package/deps/couchbase-cxx-client/third_party/docopt/docopt_private.h +676 -0
  123. package/deps/couchbase-cxx-client/third_party/docopt/docopt_util.h +122 -0
  124. package/deps/couchbase-cxx-client/third_party/docopt/docopt_value.h +341 -0
  125. package/deps/couchbase-cxx-client/third_party/docopt/examples/naval_fate.cpp +36 -0
  126. package/deps/couchbase-cxx-client/third_party/docopt/main.cpp +16 -0
  127. package/deps/couchbase-cxx-client/third_party/docopt/run_testcase.cpp +40 -0
  128. package/deps/couchbase-cxx-client/third_party/docopt/run_tests.py +72 -0
  129. package/deps/couchbase-cxx-client/third_party/docopt/testcases.docopt +957 -0
  130. package/deps/couchbase-cxx-client/tools/CMakeLists.txt +14 -0
  131. package/deps/couchbase-cxx-client/tools/cbc.cxx +65 -0
  132. package/deps/couchbase-cxx-client/tools/command.hxx +31 -0
  133. package/deps/couchbase-cxx-client/tools/command_registry.cxx +43 -0
  134. package/deps/couchbase-cxx-client/tools/command_registry.hxx +39 -0
  135. package/deps/couchbase-cxx-client/tools/get.cxx +267 -0
  136. package/deps/couchbase-cxx-client/tools/get.hxx +26 -0
  137. package/deps/couchbase-cxx-client/tools/query.cxx +441 -0
  138. package/deps/couchbase-cxx-client/tools/query.hxx +26 -0
  139. package/deps/couchbase-cxx-client/tools/utils.cxx +418 -0
  140. package/deps/couchbase-cxx-client/tools/utils.hxx +150 -0
  141. package/deps/couchbase-cxx-client/tools/version.cxx +82 -0
  142. package/deps/couchbase-cxx-client/tools/version.hxx +26 -0
  143. package/dist/authenticators.d.ts +2 -2
  144. package/dist/authenticators.js +1 -2
  145. package/dist/binding.d.ts +32 -16
  146. package/dist/cluster.js +14 -7
  147. package/dist/collection.d.ts +6 -0
  148. package/dist/collection.js +8 -0
  149. package/dist/queryexecutor.js +1 -1
  150. package/dist/queryindexmanager.d.ts +100 -4
  151. package/dist/queryindexmanager.js +344 -118
  152. package/dist/transactions.js +0 -2
  153. package/package.json +1 -1
  154. package/src/connection.cpp +2 -0
  155. package/src/connection.hpp +1 -0
  156. package/src/connection_autogen.cpp +16 -0
  157. package/src/jstocbpp_autogen.hpp +93 -23
  158. package/src/jstocbpp_basic.hpp +24 -0
  159. package/src/jstocbpp_transactions.hpp +0 -8
  160. package/tools/gen-bindings-js.js +1 -0
  161. package/tools/gen-bindings-json.py +4 -2
  162. package/deps/couchbase-cxx-client/core/transactions/logging.cxx +0 -107
@@ -138,9 +138,12 @@ class attempt_context_impl
138
138
  void commit_with_query(VoidCallback&& cb);
139
139
  void rollback_with_query(VoidCallback&& cb);
140
140
 
141
- void query_begin_work(std::function<void(std::exception_ptr)>&& cb);
141
+ void query_begin_work(std::optional<std::string> query_context, std::function<void(std::exception_ptr)>&& cb);
142
142
 
143
- void do_query(const std::string& statement, const couchbase::transactions::transaction_query_options& opts, QueryCallback&& cb);
143
+ void do_query(const std::string& statement,
144
+ const couchbase::transactions::transaction_query_options& opts,
145
+ std::optional<std::string> query_context,
146
+ QueryCallback&& cb);
144
147
  std::exception_ptr handle_query_error(const core::operations::query_response& resp);
145
148
  void wrap_query(const std::string& statement,
146
149
  const couchbase::transactions::transaction_query_options& opts,
@@ -148,6 +151,7 @@ class attempt_context_impl
148
151
  const tao::json::value& txdata,
149
152
  const std::string& hook_point,
150
153
  bool check_expiry,
154
+ std::optional<std::string> query_context,
151
155
  std::function<void(std::exception_ptr, core::operations::query_response)>&& cb);
152
156
 
153
157
  void handle_err_from_callback(std::exception_ptr e)
@@ -155,27 +159,28 @@ class attempt_context_impl
155
159
  try {
156
160
  throw e;
157
161
  } catch (const transaction_operation_failed& ex) {
158
- txn_log->error("op callback called a txn operation that threw exception {}", ex.what());
162
+ CB_ATTEMPT_CTX_LOG_ERROR(this, "op callback called a txn operation that threw exception {}", ex.what());
159
163
  op_list_.decrement_ops();
160
164
  // presumably that op called op_completed_with_error already, so
161
165
  // don't do anything here but swallow it.
162
166
  } catch (const async_operation_conflict& op_ex) {
163
167
  // the count isn't changed when this is thrown, so just swallow it and log
164
- txn_log->error("op callback called a txn operation that threw exception {}", op_ex.what());
168
+ CB_ATTEMPT_CTX_LOG_ERROR(this, "op callback called a txn operation that threw exception {}", op_ex.what());
165
169
  } catch (const op_exception& op_ex) {
166
- txn_log->warn("op callback called a txn operation that threw (and didn't handle) a op_exception {}", op_ex.what());
170
+ CB_ATTEMPT_CTX_LOG_WARNING(
171
+ this, "op callback called a txn operation that threw (and didn't handle) a op_exception {}", op_ex.what());
167
172
  errors_.push_back(
168
173
  transaction_operation_failed(error_class_from_external_exception(op_ex.cause()), op_ex.what()).cause(op_ex.cause()));
169
174
  op_list_.decrement_ops();
170
175
  } catch (const std::exception& std_ex) {
171
176
  // if the callback throws something which wasn't handled
172
177
  // we just want to handle as a rollback
173
- txn_log->error("op callback threw exception {}", std_ex.what());
178
+ CB_ATTEMPT_CTX_LOG_ERROR(this, "op callback threw exception {}", std_ex.what());
174
179
  errors_.push_back(transaction_operation_failed(FAIL_OTHER, std_ex.what()));
175
180
  op_list_.decrement_ops();
176
181
  } catch (...) {
177
182
  // could be something really arbitrary, still...
178
- txn_log->error("op callback threw unexpected exception");
183
+ CB_ATTEMPT_CTX_LOG_ERROR(this, "op callback threw unexpected exception");
179
184
  errors_.push_back(transaction_operation_failed(FAIL_OTHER, "unexpected error"));
180
185
  op_list_.decrement_ops();
181
186
  }
@@ -294,7 +299,7 @@ class attempt_context_impl
294
299
  return func();
295
300
  } catch (const async_operation_conflict& e) {
296
301
  // can't do anything here but log and eat it.
297
- error("Attempted to perform txn operation after commit/rollback started: {}", e.what());
302
+ CB_ATTEMPT_CTX_LOG_ERROR(this, "Attempted to perform txn operation after commit/rollback started: {}", e.what());
298
303
  // you cannot call op_completed_with_error, as it tries to decrement
299
304
  // the op count, however it didn't successfully increment it, so...
300
305
  op_completed_with_error_no_cache(std::move(cb), std::current_exception());
@@ -311,30 +316,6 @@ class attempt_context_impl
311
316
  }
312
317
  }
313
318
 
314
- template<typename... Args>
315
- void trace(const std::string& fmt, Args... args)
316
- {
317
- txn_log->trace(attempt_format_string + fmt, this->transaction_id(), this->id(), args...);
318
- }
319
-
320
- template<typename... Args>
321
- void debug(const std::string& fmt, Args... args)
322
- {
323
- txn_log->debug(attempt_format_string + fmt, this->transaction_id(), this->id(), args...);
324
- }
325
-
326
- template<typename... Args>
327
- void info(const std::string& fmt, Args... args)
328
- {
329
- txn_log->info(attempt_format_string + fmt, this->transaction_id(), this->id(), args...);
330
- }
331
-
332
- template<typename... Args>
333
- void error(const std::string& fmt, Args... args)
334
- {
335
- txn_log->error(attempt_format_string + fmt, this->transaction_id(), this->id(), args...);
336
- }
337
-
338
319
  std::shared_ptr<core::cluster> cluster_ref();
339
320
 
340
321
  public:
@@ -382,22 +363,28 @@ class attempt_context_impl
382
363
  };
383
364
 
384
365
  core::operations::query_response do_core_query(const std::string& statement,
385
- const couchbase::transactions::transaction_query_options& options) override;
366
+ const couchbase::transactions::transaction_query_options& options,
367
+ std::optional<std::string> query_context) override;
386
368
 
387
- couchbase::transactions::transaction_query_result_ptr do_public_query(
388
- const std::string& statement,
389
- const couchbase::transactions::transaction_query_options& opts) override;
369
+ couchbase::transactions::transaction_query_result_ptr do_public_query(const std::string& statement,
370
+ const couchbase::transactions::transaction_query_options& opts,
371
+ std::optional<std::string> query_context) override;
390
372
 
391
373
  void query(const std::string& statement,
392
374
  const couchbase::transactions::transaction_query_options& options,
375
+ std::optional<std::string> query_context,
393
376
  QueryCallback&& cb) override;
394
377
 
395
378
  void query(std::string statement,
396
379
  couchbase::transactions::transaction_query_options opts,
380
+ std::optional<std::string> query_context,
397
381
  couchbase::transactions::async_query_handler&& handler) override
398
382
  {
399
383
  query(
400
- statement, opts, [handler = std::move(handler)](std::exception_ptr err, std::optional<core::operations::query_response> resp) {
384
+ statement,
385
+ opts,
386
+ query_context,
387
+ [handler = std::move(handler)](std::exception_ptr err, std::optional<core::operations::query_response> resp) {
401
388
  if (err) {
402
389
  try {
403
390
  std::rethrow_exception(err);
@@ -192,12 +192,12 @@ class forward_compat
192
192
  auto behavior = b->check(supported);
193
193
  switch (behavior.behavior) {
194
194
  case forward_compat_behavior::FAIL_FAST_TXN:
195
- txn_log->trace("forward compatiblity FAIL_FAST_TXN");
195
+ CB_TXN_LOG_TRACE("forward compatiblity FAIL_FAST_TXN");
196
196
  return ex;
197
197
  case forward_compat_behavior::RETRY_TXN:
198
- txn_log->trace("forward compatibility RETRY_TXN");
198
+ CB_TXN_LOG_TRACE("forward compatibility RETRY_TXN");
199
199
  if (behavior.retry_delay) {
200
- txn_log->trace("delay {}ms before retrying", behavior.retry_delay->count());
200
+ CB_TXN_LOG_TRACE("delay {}ms before retrying", behavior.retry_delay->count());
201
201
  std::this_thread::sleep_for(*behavior.retry_delay);
202
202
  }
203
203
  return ex.retry();
@@ -213,7 +213,7 @@ class forward_compat
213
213
  forward_compat(tao::json::value& json)
214
214
  : json_(json)
215
215
  {
216
- txn_log->trace("creating forward_compat from {}", core::utils::json::generate(json_));
216
+ CB_TXN_LOG_TRACE("creating forward_compat from {}", core::utils::json::generate(json_));
217
217
  // parse it into the map
218
218
  for (const auto& [key, value] : json_.get_object()) {
219
219
  auto stage = create_forward_compat_stage(key);
@@ -21,6 +21,7 @@
21
21
  #include "logging.hxx"
22
22
 
23
23
  #include <chrono>
24
+ #include <fmt/format.h>
24
25
  #include <memory>
25
26
  #include <mutex>
26
27
  #include <optional>
@@ -65,19 +66,16 @@ class atr_cleanup_entry
65
66
 
66
67
  friend class compare_atr_entries;
67
68
 
68
- void check_atr_and_cleanup(std::shared_ptr<spdlog::logger> logger, transactions_cleanup_attempt* result);
69
- void cleanup_docs(std::shared_ptr<spdlog::logger> logger, durability_level dl);
70
- void cleanup_entry(std::shared_ptr<spdlog::logger> logger, durability_level dl);
71
- void commit_docs(std::shared_ptr<spdlog::logger> logger, std::optional<std::vector<doc_record>> docs, durability_level dl);
72
- void remove_docs(std::shared_ptr<spdlog::logger> logger, std::optional<std::vector<doc_record>> docs, durability_level dl);
73
- void remove_docs_staged_for_removal(std::shared_ptr<spdlog::logger> logger,
74
- std::optional<std::vector<doc_record>> docs,
75
- durability_level dl);
76
- void remove_txn_links(std::shared_ptr<spdlog::logger> logger, std::optional<std::vector<doc_record>> docs, durability_level dl);
77
- void do_per_doc(std::shared_ptr<spdlog::logger> logger,
78
- std::vector<doc_record> docs,
69
+ void check_atr_and_cleanup(transactions_cleanup_attempt* result);
70
+ void cleanup_docs(durability_level dl);
71
+ void cleanup_entry(durability_level dl);
72
+ void commit_docs(std::optional<std::vector<doc_record>> docs, durability_level dl);
73
+ void remove_docs(std::optional<std::vector<doc_record>> docs, durability_level dl);
74
+ void remove_docs_staged_for_removal(std::optional<std::vector<doc_record>> docs, durability_level dl);
75
+ void remove_txn_links(std::optional<std::vector<doc_record>> docs, durability_level dl);
76
+ void do_per_doc(std::vector<doc_record> docs,
79
77
  bool require_crc_to_match,
80
- const std::function<void(std::shared_ptr<spdlog::logger>, transaction_get_result&, bool)>& call);
78
+ const std::function<void(transaction_get_result&, bool)>& call);
81
79
 
82
80
  public:
83
81
  explicit atr_cleanup_entry(attempt_context& ctx);
@@ -88,8 +86,27 @@ class atr_cleanup_entry
88
86
 
89
87
  explicit atr_cleanup_entry(const core::document_id& atr_id, const std::string& attempt_id, const transactions_cleanup& cleanup);
90
88
 
91
- void clean(std::shared_ptr<spdlog::logger> logger, transactions_cleanup_attempt* result = nullptr);
89
+ void clean(transactions_cleanup_attempt* result = nullptr);
92
90
  bool ready() const;
91
+ couchbase::core::document_id atr_id() const
92
+ {
93
+ return atr_id_;
94
+ }
95
+
96
+ std::string attempt_id() const
97
+ {
98
+ return attempt_id_;
99
+ }
100
+
101
+ bool check_if_expired() const
102
+ {
103
+ return check_if_expired_;
104
+ }
105
+
106
+ std::chrono::time_point<std::chrono::steady_clock> min_start_time() const
107
+ {
108
+ return min_start_time_;
109
+ };
93
110
 
94
111
  template<typename OStream>
95
112
  friend OStream& operator<<(OStream& os, const atr_cleanup_entry& e)
@@ -124,3 +141,24 @@ class atr_cleanup_queue
124
141
  };
125
142
 
126
143
  } // namespace couchbase::core::transactions
144
+
145
+ template<>
146
+ struct fmt::formatter<couchbase::core::transactions::atr_cleanup_entry> {
147
+ public:
148
+ template<typename ParseContext>
149
+ constexpr auto parse(ParseContext& ctx)
150
+ {
151
+ return ctx.begin();
152
+ }
153
+
154
+ template<typename FormatContext>
155
+ auto format(const couchbase::core::transactions::atr_cleanup_entry& e, FormatContext& ctx) const
156
+ {
157
+ return format_to(ctx.out(),
158
+ "atr_cleanup_entry{{ atr_id: {}, attempt_id: {}, check_if_expired: {}, min_start_time: {} }}",
159
+ e.atr_id(),
160
+ e.attempt_id(),
161
+ e.check_if_expired(),
162
+ std::chrono::duration_cast<std::chrono::milliseconds>(e.min_start_time().time_since_epoch()).count());
163
+ }
164
+ };
@@ -15,6 +15,7 @@
15
15
  */
16
16
  #pragma once
17
17
 
18
+ #include <fmt/format.h>
18
19
  #include <string>
19
20
  #include <vector>
20
21
 
@@ -56,5 +57,29 @@ struct client_record_details {
56
57
  return os;
57
58
  }
58
59
  };
59
-
60
60
  } // namespace couchbase::core::transactions
61
+ template<>
62
+ struct fmt::formatter<couchbase::core::transactions::client_record_details> {
63
+ public:
64
+ template<typename ParseContext>
65
+ constexpr auto parse(ParseContext& ctx)
66
+ {
67
+ return ctx.begin();
68
+ }
69
+
70
+ template<typename FormatContext>
71
+ auto format(const couchbase::core::transactions::client_record_details& r, FormatContext& ctx) const
72
+ {
73
+ return format_to(ctx.out(),
74
+ "client_record:{{ client_uuid:: {}, active_clients: {}, index_of_this_client: {}, existing_clients: {}, "
75
+ "expired_clients: {}, override_enabled: {}, override_expires: {}, cas_now_nanos: {} }}",
76
+ r.client_uuid,
77
+ r.num_active_clients,
78
+ r.index_of_this_client,
79
+ r.num_existing_clients,
80
+ r.num_expired_clients,
81
+ r.override_enabled,
82
+ r.override_expires,
83
+ r.cas_now_nanos);
84
+ }
85
+ };
@@ -76,3 +76,24 @@ struct doc_record {
76
76
  core::document_id id_;
77
77
  };
78
78
  } // namespace couchbase::core::transactions
79
+
80
+ template<>
81
+ struct fmt::formatter<couchbase::core::transactions::doc_record> {
82
+ public:
83
+ template<typename ParseContext>
84
+ constexpr auto parse(ParseContext& ctx)
85
+ {
86
+ return ctx.begin();
87
+ }
88
+
89
+ template<typename FormatContext>
90
+ constexpr auto format(const couchbase::core::transactions::doc_record& r, FormatContext& ctx) const
91
+ {
92
+ return format_to(ctx.out(),
93
+ "doc_record:{{ bucket: {}, scope: {}, collection: {}, key: {} }}",
94
+ r.document_id().bucket(),
95
+ r.document_id().scope(),
96
+ r.document_id().collection(),
97
+ r.document_id().key());
98
+ }
99
+ };
@@ -15,26 +15,48 @@
15
15
  */
16
16
  #pragma once
17
17
 
18
- #include <spdlog/fmt/ostr.h>
19
- #include <spdlog/logger.h>
20
-
21
- #define TXN_LOG "transactions"
22
- #define ATTEMPT_CLEANUP_LOG "attempt_cleanup"
23
- #define LOST_ATTEMPT_CLEANUP_LOG "lost_attempt_cleanup"
18
+ #include <core/logger/logger.hxx>
24
19
 
25
20
  namespace couchbase::core::transactions
26
21
  {
27
- static const std::string attempt_format_string("[{}/{}]:");
28
-
29
- std::shared_ptr<spdlog::logger>
30
- init_txn_log();
31
- std::shared_ptr<spdlog::logger>
32
- init_attempt_cleanup_log();
33
- std::shared_ptr<spdlog::logger>
34
- init_lost_attempts_log();
35
-
36
- static std::shared_ptr<spdlog::logger> txn_log = init_txn_log();
37
- static std::shared_ptr<spdlog::logger> attempt_cleanup_log = init_attempt_cleanup_log();
38
- static std::shared_ptr<spdlog::logger> lost_attempts_cleanup_log = init_lost_attempts_log();
22
+ static const std::string txn_format_string("[transactions] - ");
23
+ static const std::string attempt_format_string("[transactions]({}/{}) - ");
24
+ static const std::string lost_attempt_format_string("[lost_attempt_cleanup]({}) - ");
25
+ static const std::string attempt_cleanup_format_string("[attempt_cleanup] - ");
26
+
27
+ #define CB_TXN_LOG(level, ...) COUCHBASE_LOG(__FILE__, __LINE__, COUCHBASE_LOGGER_FUNCTION, level, __VA_ARGS__)
28
+
29
+ #define ADD_CTX(ctx, ...) fmt::format(attempt_format_string, ctx->transaction_id(), ctx->id()) + __VA_ARGS__
30
+ #define ADD_LOST_ATTEMPT(ctx, ...) fmt::format(couchbase::core::transactions::lost_attempt_format_string, fmt::ptr(ctx)) + __VA_ARGS__
31
+ #define ADD_ATTEMPT_CLEANUP(...) couchbase::core::transactions::attempt_cleanup_format_string + __VA_ARGS__
32
+ #define ADD_TXN(...) couchbase::core::transactions::txn_format_string + __VA_ARGS__
33
+
34
+ #define CB_ATTEMPT_CTX_LOG_TRACE(ctx, ...) CB_TXN_LOG(couchbase::core::logger::level::trace, ADD_CTX(ctx, __VA_ARGS__))
35
+ #define CB_ATTEMPT_CTX_LOG_DEBUG(ctx, ...) CB_TXN_LOG(couchbase::core::logger::level::debug, ADD_CTX(ctx, __VA_ARGS__))
36
+ #define CB_ATTEMPT_CTX_LOG_INFO(ctx, ...) CB_TXN_LOG(couchbase::core::logger::level::info, ADD_CTX(ctx, __VA_ARGS__))
37
+ #define CB_ATTEMPT_CTX_LOG_WARNING(ctx, ...) CB_TXN_LOG(couchbase::core::logger::level::warn, ADD_CTX(ctx, __VA_ARGS__))
38
+ #define CB_ATTEMPT_CTX_LOG_ERROR(ctx, ...) CB_TXN_LOG(couchbase::core::logger::level::err, ADD_CTX(ctx, __VA_ARGS__))
39
+ #define CB_ATTEMPT_CTX_LOG_CRITICAL(ctx, ...) CB_TXN_LOG(couchbase::core::logger::level::critical, ADD_CTX(ctx, __VA_ARGS__))
40
+
41
+ #define CB_LOST_ATTEMPT_CLEANUP_LOG_TRACE(...) CB_TXN_LOG(couchbase::core::logger::level::trace, ADD_LOST_ATTEMPT(this, __VA_ARGS__))
42
+ #define CB_LOST_ATTEMPT_CLEANUP_LOG_DEBUG(...) CB_TXN_LOG(couchbase::core::logger::level::debug, ADD_LOST_ATTEMPT(this, __VA_ARGS__))
43
+ #define CB_LOST_ATTEMPT_CLEANUP_LOG_INFO(...) CB_TXN_LOG(couchbase::core::logger::level::info, ADD_LOST_ATTEMPT(this, __VA_ARGS__))
44
+ #define CB_LOST_ATTEMPT_CLEANUP_LOG_WARNING(...) CB_TXN_LOG(couchbase::core::logger::level::warn, ADD_LOST_ATTEMPT(this, __VA_ARGS__))
45
+ #define CB_LOST_ATTEMPT_CLEANUP_LOG_ERROR(...) CB_TXN_LOG(couchbase::core::logger::level::err, ADD_LOST_ATTEMPT(this, __VA_ARGS__))
46
+ #define CB_LOST_ATTEMPT_CLEANUP_LOG_CRITICAL(...) CB_TXN_LOG(couchbase::core::logger::level::critical, ADD_LOST_ATTEMPT(this, __VA_ARGS__))
47
+
48
+ #define CB_ATTEMPT_CLEANUP_LOG_TRACE(...) CB_TXN_LOG(couchbase::core::logger::level::trace, ADD_ATTEMPT_CLEANUP(__VA_ARGS__))
49
+ #define CB_ATTEMPT_CLEANUP_LOG_DEBUG(...) CB_TXN_LOG(couchbase::core::logger::level::debug, ADD_ATTEMPT_CLEANUP(__VA_ARGS__))
50
+ #define CB_ATTEMPT_CLEANUP_LOG_INFO(...) CB_TXN_LOG(couchbase::core::logger::level::info, ADD_ATTEMPT_CLEANUP(__VA_ARGS__))
51
+ #define CB_ATTEMPT_CLEANUP_LOG_WARNING(...) CB_TXN_LOG(couchbase::core::logger::level::warn, ADD_ATTEMPT_CLEANUP(__VA_ARGS__))
52
+ #define CB_ATTEMPT_CLEANUP_LOG_ERROR(...) CB_TXN_LOG(couchbase::core::logger::level::err, ADD_ATTEMPT_CLEANUP(__VA_ARGS__))
53
+ #define CB_ATTEMPT_CLEANUP_LOG_CRITICAL(...) CB_TXN_LOG(couchbase::core::logger::level::critical, ADD_ATTEMPT_CLEANUP(__VA_ARGS__))
54
+
55
+ #define CB_TXN_LOG_TRACE(...) CB_TXN_LOG(couchbase::core::logger::level::trace, ADD_TXN(__VA_ARGS__))
56
+ #define CB_TXN_LOG_DEBUG(...) CB_TXN_LOG(couchbase::core::logger::level::debug, ADD_TXN(__VA_ARGS__))
57
+ #define CB_TXN_LOG_INFO(...) CB_TXN_LOG(couchbase::core::logger::level::info, ADD_TXN(__VA_ARGS__))
58
+ #define CB_TXN_LOG_WARNING(...) CB_TXN_LOG(couchbase::core::logger::level::warn, ADD_TXN(__VA_ARGS__))
59
+ #define CB_TXN_LOG_ERROR(...) CB_TXN_LOG(couchbase::core::logger::level::err, ADD_TXN(__VA_ARGS__))
60
+ #define CB_TXN_LOG_CRITICAL(...) CB_TXN_LOG(couchbase::core::logger::level::critical, ADD_TXN(__VA_ARGS__))
39
61
 
40
62
  } // namespace couchbase::core::transactions
@@ -149,6 +149,11 @@ class transaction_context
149
149
 
150
150
  void remove(const transaction_get_result& doc, async_attempt_context::VoidCallback&& cb);
151
151
 
152
+ void query(const std::string& statement,
153
+ const couchbase::transactions::transaction_query_options& opts,
154
+ std::optional<std::string> query_context,
155
+ async_attempt_context::QueryCallback&& cb);
156
+
152
157
  void query(const std::string& statement,
153
158
  const couchbase::transactions::transaction_query_options& opts,
154
159
  async_attempt_context::QueryCallback&& cb);
@@ -22,6 +22,7 @@
22
22
 
23
23
  #include "couchbase/codec/tao_json_serializer.hxx"
24
24
 
25
+ #include <fmt/format.h>
25
26
  #include <optional>
26
27
  #include <string>
27
28
  #include <vector>
@@ -268,3 +269,28 @@ struct result : result_base {
268
269
  };
269
270
  } // namespace transactions
270
271
  } // namespace couchbase::core
272
+
273
+ template<>
274
+ struct fmt::formatter<couchbase::core::transactions::result> {
275
+ public:
276
+ template<typename ParseContext>
277
+ constexpr auto parse(ParseContext& ctx)
278
+ {
279
+ return ctx.begin();
280
+ }
281
+
282
+ template<typename FormatContext>
283
+ constexpr auto format(const couchbase::core::transactions::result& r, FormatContext& ctx) const
284
+ {
285
+ return format_to(ctx.out(),
286
+ "result:{{ rc: {}, strerror: {}, cas: {}, is_deleted: {}, datatype: {}, flags: {}, raw_value: {:.{}} }}",
287
+ r.rc,
288
+ r.strerror(),
289
+ r.cas,
290
+ r.is_deleted,
291
+ r.datatype,
292
+ r.flags,
293
+ couchbase::core::transactions::to_string(r.raw_value),
294
+ r.raw_value.size() > 1024 ? 1024 : r.raw_value.size());
295
+ }
296
+ };