You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2024/11/04 08:05:13 UTC

[PR] chore(enhancement): change is_txn_mode to txn_context_enabled [kvrocks]

mapleFU opened a new pull request, #2644:
URL: https://github.com/apache/kvrocks/pull/2644

   `is_txn_mode` is used both in storage and Context, so renaming the argument


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(enhancement): rename is_txn_mode to txn_context_enabled [kvrocks]

Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2644:
URL: https://github.com/apache/kvrocks/pull/2644#discussion_r1828022829


##########
src/storage/storage.cc:
##########
@@ -705,13 +705,13 @@ rocksdb::Status Storage::writeToDB(engine::Context &ctx, const rocksdb::WriteOpt
     updates->PutLogData(ServerLogData(kReplIdLog, replid_).Encode());
   }
 
-  if (ctx.is_txn_mode) {
-    if (ctx.batch == nullptr) {
-      ctx.batch = std::make_unique<rocksdb::WriteBatchWithIndex>();
+  if (ctx.txn_context_enabled) {
+    if (ctx.batch != nullptr) {
+      WriteBatchIndexer handle(ctx);
+      auto s = updates->Iterate(&handle);
+      if (!s.ok()) return s;
+      ctx.batch = nullptr;

Review Comment:
   Got it.
   
   And why do we now avoid to create a new write batch if ctx.batch is null?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(enhancement): rename is_txn_mode to txn_context_enabled [kvrocks]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU merged PR #2644:
URL: https://github.com/apache/kvrocks/pull/2644


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(enhancement): rename is_txn_mode to txn_context_enabled [kvrocks]

Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2644:
URL: https://github.com/apache/kvrocks/pull/2644#discussion_r1828024050


##########
src/storage/storage.cc:
##########
@@ -705,13 +705,13 @@ rocksdb::Status Storage::writeToDB(engine::Context &ctx, const rocksdb::WriteOpt
     updates->PutLogData(ServerLogData(kReplIdLog, replid_).Encode());
   }
 
-  if (ctx.is_txn_mode) {
-    if (ctx.batch == nullptr) {
-      ctx.batch = std::make_unique<rocksdb::WriteBatchWithIndex>();
+  if (ctx.txn_context_enabled) {
+    if (ctx.batch != nullptr) {
+      WriteBatchIndexer handle(ctx);
+      auto s = updates->Iterate(&handle);
+      if (!s.ok()) return s;
+      ctx.batch = nullptr;

Review Comment:
   Ahh I think no actually write happens so we can omit it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(enhancement): rename is_txn_mode to txn_context_enabled [kvrocks]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #2644:
URL: https://github.com/apache/kvrocks/pull/2644#issuecomment-2456814411

   A bug exists in this refactor, will dive into it tomorrow


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(enhancement): rename is_txn_mode to txn_context_enabled [kvrocks]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #2644:
URL: https://github.com/apache/kvrocks/pull/2644#discussion_r1827857464


##########
src/storage/storage.cc:
##########
@@ -705,13 +705,13 @@ rocksdb::Status Storage::writeToDB(engine::Context &ctx, const rocksdb::WriteOpt
     updates->PutLogData(ServerLogData(kReplIdLog, replid_).Encode());
   }
 
-  if (ctx.is_txn_mode) {
-    if (ctx.batch == nullptr) {
-      ctx.batch = std::make_unique<rocksdb::WriteBatchWithIndex>();
+  if (ctx.txn_context_enabled) {
+    if (ctx.batch != nullptr) {
+      WriteBatchIndexer handle(ctx);
+      auto s = updates->Iterate(&handle);
+      if (!s.ok()) return s;
+      ctx.batch = nullptr;

Review Comment:
   comment aboved



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(enhancement): rename is_txn_mode to txn_context_enabled [kvrocks]

Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2644:
URL: https://github.com/apache/kvrocks/pull/2644#discussion_r1827610213


##########
src/storage/storage.cc:
##########
@@ -705,13 +705,13 @@ rocksdb::Status Storage::writeToDB(engine::Context &ctx, const rocksdb::WriteOpt
     updates->PutLogData(ServerLogData(kReplIdLog, replid_).Encode());
   }
 
-  if (ctx.is_txn_mode) {
-    if (ctx.batch == nullptr) {
-      ctx.batch = std::make_unique<rocksdb::WriteBatchWithIndex>();
+  if (ctx.txn_context_enabled) {
+    if (ctx.batch != nullptr) {
+      WriteBatchIndexer handle(ctx);
+      auto s = updates->Iterate(&handle);
+      if (!s.ok()) return s;
+      ctx.batch = nullptr;

Review Comment:
   Why do we need to clear ctx.batch if it's not null?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(enhancement): change is_txn_mode to txn_context_enabled [kvrocks]

Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2644:
URL: https://github.com/apache/kvrocks/pull/2644#discussion_r1827610213


##########
src/storage/storage.cc:
##########
@@ -705,13 +705,13 @@ rocksdb::Status Storage::writeToDB(engine::Context &ctx, const rocksdb::WriteOpt
     updates->PutLogData(ServerLogData(kReplIdLog, replid_).Encode());
   }
 
-  if (ctx.is_txn_mode) {
-    if (ctx.batch == nullptr) {
-      ctx.batch = std::make_unique<rocksdb::WriteBatchWithIndex>();
+  if (ctx.txn_context_enabled) {
+    if (ctx.batch != nullptr) {
+      WriteBatchIndexer handle(ctx);
+      auto s = updates->Iterate(&handle);
+      if (!s.ok()) return s;
+      ctx.batch = nullptr;

Review Comment:
   Why we need to clear ctx.batch if it's not null?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(enhancement): rename is_txn_mode to txn_context_enabled [kvrocks]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2644:
URL: https://github.com/apache/kvrocks/pull/2644#issuecomment-2475359427

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2644) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2644&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2644&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_kvrocks&pullRequest=2644&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [61.1% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2644&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.1% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2644&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2644)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org