You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "caipengbo (via GitHub)" <gi...@apache.org> on 2024/01/24 02:35:40 UTC

[PR] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   When we delete data in kvrocks, we will write delete makers to rocksdb. When our data size reaches `max-db-size`, we can't delete data. 
   
   For operations that delete data, we should ignore the `max-db-size` limit and allow the deletion to proceed, so we can clean up the data.
   
   In addition, for some aux information(written into `propagate` column family), we should also ignore `max-db-size`.


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   > The better way is to check if it reached the max db size if it's a write command. And add an extra flag to identify if the write command is allowed to run even though reached the limit of db size.
   
   That sounds better, I'll try to modify 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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   ## [![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=2047) **Quality Gate passed**  
   The SonarCloud Quality Gate passed, but some issues were introduced.
   
   [1 New issue](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2047&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_kvrocks&pullRequest=2047&resolved=false&inNewCodePeriod=true)  
   [72.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2047&metric=new_coverage&view=list)  
   [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2047&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2047)
   
   


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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


##########
src/commands/cmd_list.cc:
##########
@@ -861,9 +861,9 @@ REDIS_REGISTER_COMMANDS(MakeCmdAttr<CommandBLPop>("blpop", -3, "write no-script"
                         MakeCmdAttr<CommandLPush>("lpush", -3, "write", 1, 1, 1),
                         MakeCmdAttr<CommandLPushX>("lpushx", -3, "write", 1, 1, 1),
                         MakeCmdAttr<CommandLRange>("lrange", 4, "read-only", 1, 1, 1),
-                        MakeCmdAttr<CommandLRem>("lrem", 4, "write", 1, 1, 1),
+                        MakeCmdAttr<CommandLRem>("lrem", 4, "write no-dbsize-check", 1, 1, 1),
                         MakeCmdAttr<CommandLSet>("lset", 4, "write", 1, 1, 1),
-                        MakeCmdAttr<CommandLTrim>("ltrim", 4, "write", 1, 1, 1),
+                        MakeCmdAttr<CommandLTrim>("ltrim", 4, "write no-dbsize-check", 1, 1, 1),
                         MakeCmdAttr<CommandLMPop>("lmpop", -4, "write", CommandLMPop::keyRangeGen),
                         MakeCmdAttr<CommandRPop>("rpop", -2, "write", 1, 1, 1),

Review Comment:
   I didn't add this flag for any of these commands. The way I think about it is that there might be a lot of fields for this type(list, zset...),  and the db space release will be slow if the user removes them one by one. I want to guide the user to remove many elements(remove a range) at once. So I only added trim, etc.



-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   Will this logic confuse users?
   For example, when the data size reaches the max-db-size, if the user deletes a large amount of data, it will cause the db size to significantly exceed the db-size they have configured.


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   > Will this logic confuse users?
   
   There is also a risk of confusion, which we can illustrate in the configuration file. In addition, these delete makers will be eliminated during compaction, and the data size will decrease. @jihuayu 


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   @caipengbo The better way is to check if it reached the max db size if it's a write command. And add an extra flag to identify if the write command is allowed to run even though reached the limit of db size. What you do think about this?


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2047) **Quality Gate failed**  
   Failed conditions
   
   [58.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2047&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2047)
   
   


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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


##########
src/storage/storage.h:
##########
@@ -243,7 +245,7 @@ class Storage {
   Config *config_ = nullptr;
   std::vector<rocksdb::ColumnFamilyHandle *> cf_handles_;
   LockManager lock_mgr_;
-  bool db_size_limit_reached_ = false;
+  std::atomic<bool> db_size_limit_reached_{false};

Review Comment:
   Why change it to atomic? I don't quite understand.
   



-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2047) **Quality Gate failed**  
   Failed conditions
   
   [58.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2047&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2047)
   
   


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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


##########
src/commands/cmd_list.cc:
##########
@@ -861,9 +861,9 @@ REDIS_REGISTER_COMMANDS(MakeCmdAttr<CommandBLPop>("blpop", -3, "write no-script"
                         MakeCmdAttr<CommandLPush>("lpush", -3, "write", 1, 1, 1),
                         MakeCmdAttr<CommandLPushX>("lpushx", -3, "write", 1, 1, 1),
                         MakeCmdAttr<CommandLRange>("lrange", 4, "read-only", 1, 1, 1),
-                        MakeCmdAttr<CommandLRem>("lrem", 4, "write", 1, 1, 1),
+                        MakeCmdAttr<CommandLRem>("lrem", 4, "write no-dbsize-check", 1, 1, 1),
                         MakeCmdAttr<CommandLSet>("lset", 4, "write", 1, 1, 1),
-                        MakeCmdAttr<CommandLTrim>("ltrim", 4, "write", 1, 1, 1),
+                        MakeCmdAttr<CommandLTrim>("ltrim", 4, "write no-dbsize-check", 1, 1, 1),
                         MakeCmdAttr<CommandLMPop>("lmpop", -4, "write", CommandLMPop::keyRangeGen),
                         MakeCmdAttr<CommandRPop>("rpop", -2, "write", 1, 1, 1),

Review Comment:
   Are these commands also suitable for `no-dbsize-check`?
   
   Maybe we need to carefully cover all such commands as much as possible.



-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   ## [![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=2047) **Quality Gate passed**  
   The SonarCloud Quality Gate passed, but some issues were introduced.
   
   [1 New issue](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2047&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_kvrocks&pullRequest=2047&resolved=false&inNewCodePeriod=true)  
   [63.2% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2047&metric=new_coverage&view=list)  
   [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2047&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2047)
   
   


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   > @caipengbo The better way is to check if it reached the max db size if it's a write command before running. And add an extra flag to identify if the write command is allowed to run even though reached the limit of db size. What you do think about this?
   
   I think we can make some reserved db space:
   - When free db space is below 100MB, only delete commands write and system write can work.
   - When free db space is below 10MB, only system write can work.


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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

   Your idea is similar to what I did on our personalized version kvrocks. @jihuayu 
   
    It's just that we don't want to save disk space, we want to avoid OOM, because if we delete a lot of data, we can create a very large WAL, which caches a lot of data in memory, which is very easy to cause OOM(we have encountered it), and even worse, we can't restart our program, because we need to replay the WAL at startup. At this point, all unflushed data will be loaded into memory, again leading to an OOM!
   
   So we find all the places in the program where kvrocks can generate a large WAL, check it, and if it's larger than `max-write-batch-size`, we return an error so the user can't do it.
   > This is a feature I plan to implement in some subsequent PRs (about memory control).


-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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


##########
src/storage/storage.h:
##########
@@ -171,6 +171,8 @@ class Storage {
   void PurgeOldBackups(uint32_t num_backups_to_keep, uint32_t backup_max_keep_hours);
   uint64_t GetTotalSize(const std::string &ns = kDefaultNamespace);
   void CheckDBSizeLimit();
+  bool ReachedDBSizeLimit() { return db_size_limit_reached_; }
+  void SetDBSizeLimit(bool limit) { db_size_limit_reached_ = limit; }

Review Comment:
   This flag will be modified by flush or compact, but for now it's only for testing (debug), so I think it's good enough.



-- 
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] Ignore max-db-size limit when deleting data or writing aux informations [kvrocks]

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


##########
src/storage/storage.h:
##########
@@ -243,7 +245,7 @@ class Storage {
   Config *config_ = nullptr;
   std::vector<rocksdb::ColumnFamilyHandle *> cf_handles_;
   LockManager lock_mgr_;
-  bool db_size_limit_reached_ = false;
+  std::atomic<bool> db_size_limit_reached_{false};

Review Comment:
   This variable will be modified by multiple threads during compact and flush.



-- 
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