You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by GitBox <gi...@apache.org> on 2021/01/29 07:34:21 UTC
[GitHub] [incubator-pegasus] levy5307 opened a new pull request #688: fix: clean the specified key
levy5307 opened a new pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688
### What problem does this PR solve? <!--add issue link with summary if exists-->
clean the specified key with ttl > 3
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] levy5307 commented on a change in pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
levy5307 commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r566795775
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -23,12 +23,38 @@
#include <atomic>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/merge_operator.h>
+#include <base/pegasus_key_schema.h>
#include "base/pegasus_utils.h"
#include "base/pegasus_value_schema.h"
namespace pegasus {
namespace server {
+inline bool need_clean_key(const rocksdb::Slice &key, uint32_t expire_ts, uint32_t now_ts)
+{
+ std::vector<std::string> cleaned_hash_key_prefix = {"raw_tts_audio:", "stored_tts_url_info:"};
Review comment:
这里已经改成static了,忘记上传了
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] levy5307 commented on a change in pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
levy5307 commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r566796234
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -58,7 +84,13 @@ class KeyWithTTLCompactionFilter : public rocksdb::CompactionFilter
*value_changed = true;
return false;
}
- return check_if_ts_expired(utils::epoch_now(), expire_ts);
+
+ uint32_t now_ts = utils::epoch_now();
+ if (check_if_ts_expired(now_ts, expire_ts)) {
+ return true;
+ }
+
+ return need_clean_key(key, expire_ts, now_ts);
Review comment:
其实可以不加判断,当前这个集群只有speech这一个表,反正也是救急用
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] levy5307 closed pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
levy5307 closed pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] neverchanje commented on a change in pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
neverchanje commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r566777738
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -23,19 +23,49 @@
#include <atomic>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/merge_operator.h>
+#include <base/pegasus_key_schema.h>
#include "base/pegasus_utils.h"
#include "base/pegasus_value_schema.h"
namespace pegasus {
namespace server {
+inline bool need_clean_key(const rocksdb::Slice &key, uint32_t expire_ts, uint32_t now_ts)
+{
+ std::vector<std::string> cleaned_hash_key_prefix = {"raw_tts_audio:", "stored_tts_url_info:"};
Review comment:
```suggestion
const std::vector<std::string> cleaned_hash_key_prefix = {"raw_tts_audio:", "stored_tts_url_info:"};
```
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -23,12 +23,38 @@
#include <atomic>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/merge_operator.h>
+#include <base/pegasus_key_schema.h>
#include "base/pegasus_utils.h"
#include "base/pegasus_value_schema.h"
namespace pegasus {
namespace server {
+inline bool need_clean_key(const rocksdb::Slice &key, uint32_t expire_ts, uint32_t now_ts)
+{
+ std::vector<std::string> cleaned_hash_key_prefix = {"raw_tts_audio:", "stored_tts_url_info:"};
+
+ uint32_t oneday_sec = 24 * 60 * 60;
+ // includes expire_tx == 0
+ if (expire_ts < now_ts + 3 * oneday_sec) {
+ return false;
+ }
+
+ std::string hash_key, sort_key;
+ pegasus_restore_key(dsn::blob(key.data(), 0, key.size()), hash_key, sort_key);
+ for (const auto &key_prefix : cleaned_hash_key_prefix) {
+ if (hash_key.length() >= key_prefix.length() &&
+ 0 == hash_key.compare(0, key_prefix.length(), key_prefix)) {
+ static int count = 0;
+ if (count++ / 1000 == 0) {
Review comment:
```suggestion
if (count++ % 1000 == 0) {
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] qinzuoyan commented on a change in pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
qinzuoyan commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r566785486
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -23,12 +23,38 @@
#include <atomic>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/merge_operator.h>
+#include <base/pegasus_key_schema.h>
#include "base/pegasus_utils.h"
#include "base/pegasus_value_schema.h"
namespace pegasus {
namespace server {
+inline bool need_clean_key(const rocksdb::Slice &key, uint32_t expire_ts, uint32_t now_ts)
+{
+ std::vector<std::string> cleaned_hash_key_prefix = {"raw_tts_audio:", "stored_tts_url_info:"};
Review comment:
每次调用need_clean_key都要构造一次vector
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -58,7 +84,13 @@ class KeyWithTTLCompactionFilter : public rocksdb::CompactionFilter
*value_changed = true;
return false;
}
- return check_if_ts_expired(utils::epoch_now(), expire_ts);
+
+ uint32_t now_ts = utils::epoch_now();
+ if (check_if_ts_expired(now_ts, expire_ts)) {
+ return true;
+ }
+
+ return need_clean_key(key, expire_ts, now_ts);
Review comment:
实际上我只需要对一个表做这个清理数据操作,有没有办法获取到表ID,只对这个表ID执行这个函数?
##########
File path: src/server/test/key_ttl_compaction_filter_test.cpp
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <gtest/gtest.h>
+#include "server/key_ttl_compaction_filter.h"
+
+namespace pegasus {
+namespace server {
+
+TEST(key_ttl_compaction_filter_test, need_clean_key)
+{
+ int32_t oneday_sec = 24 * 60 * 60;
+
+ struct
+ {
+ std::string hash_key;
+ int32_t expire_sec_from_now;
+ bool need_clean;
+ } tests[] = {{"raw_tts_audio:", 100, false},
+ {"raw_tts_audio:xxx", 100, false},
+ {"raw_tts_audio:xxx", 3 * oneday_sec - 1, false},
+ {"raw_tts_audio:xxx", 3 * oneday_sec, true},
+ {"raw_tts_audio", 4 * oneday_sec, false},
+ {"stored_tts_url_info:", 100, false},
+ {"stored_tts_url_info:xxx", 100, false},
+ {"stored_tts_url_info:xxx", 3 * oneday_sec - 1, false},
+ {"stored_tts_url_info:xxx", 3 * oneday_sec, true},
+ {"stored_tts_url_info", 4 * oneday_sec, false},
+ {"donot_clean_key", 100, false},
+ {"donot_clean_key", 4 * oneday_sec, false}};
Review comment:
没有测试到 tts = 0 的场景
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] levy5307 commented on a change in pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
levy5307 commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r566795775
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -23,12 +23,38 @@
#include <atomic>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/merge_operator.h>
+#include <base/pegasus_key_schema.h>
#include "base/pegasus_utils.h"
#include "base/pegasus_value_schema.h"
namespace pegasus {
namespace server {
+inline bool need_clean_key(const rocksdb::Slice &key, uint32_t expire_ts, uint32_t now_ts)
+{
+ std::vector<std::string> cleaned_hash_key_prefix = {"raw_tts_audio:", "stored_tts_url_info:"};
Review comment:
这里已经改成static了,忘记上传了
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] levy5307 commented on a change in pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
levy5307 commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r566797520
##########
File path: src/server/test/key_ttl_compaction_filter_test.cpp
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <gtest/gtest.h>
+#include "server/key_ttl_compaction_filter.h"
+
+namespace pegasus {
+namespace server {
+
+TEST(key_ttl_compaction_filter_test, need_clean_key)
+{
+ int32_t oneday_sec = 24 * 60 * 60;
+
+ struct
+ {
+ std::string hash_key;
+ int32_t expire_sec_from_now;
+ bool need_clean;
+ } tests[] = {{"raw_tts_audio:", 100, false},
+ {"raw_tts_audio:xxx", 100, false},
+ {"raw_tts_audio:xxx", 3 * oneday_sec - 1, false},
+ {"raw_tts_audio:xxx", 3 * oneday_sec, true},
+ {"raw_tts_audio", 4 * oneday_sec, false},
+ {"stored_tts_url_info:", 100, false},
+ {"stored_tts_url_info:xxx", 100, false},
+ {"stored_tts_url_info:xxx", 3 * oneday_sec - 1, false},
+ {"stored_tts_url_info:xxx", 3 * oneday_sec, true},
+ {"stored_tts_url_info", 4 * oneday_sec, false},
+ {"donot_clean_key", 100, false},
+ {"donot_clean_key", 4 * oneday_sec, false}};
Review comment:
这里确实没有,不过描述里的manual test是有覆盖的。我补一下
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] qinzuoyan commented on a change in pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
qinzuoyan commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r567222755
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -58,7 +84,13 @@ class KeyWithTTLCompactionFilter : public rocksdb::CompactionFilter
*value_changed = true;
return false;
}
- return check_if_ts_expired(utils::epoch_now(), expire_ts);
+
+ uint32_t now_ts = utils::epoch_now();
+ if (check_if_ts_expired(now_ts, expire_ts)) {
+ return true;
+ }
+
+ return need_clean_key(key, expire_ts, now_ts);
Review comment:
既然只有这一个表,那就没问题
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org
[GitHub] [incubator-pegasus] neverchanje commented on a change in pull request #688: fix: clean the specified key
Posted by GitBox <gi...@apache.org>.
neverchanje commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r566818037
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -58,7 +84,13 @@ class KeyWithTTLCompactionFilter : public rocksdb::CompactionFilter
*value_changed = true;
return false;
}
- return check_if_ts_expired(utils::epoch_now(), expire_ts);
+
+ uint32_t now_ts = utils::epoch_now();
+ if (check_if_ts_expired(now_ts, expire_ts)) {
+ return true;
+ }
+
+ return need_clean_key(key, expire_ts, now_ts);
Review comment:
可以不加,compaction filter拿不到appid,想拿到appid需要增加额外代码
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org