This is an automated email from the ASF dual-hosted git repository.
xiaobiao pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 8fc2dc4c perf: Set async_io default value to yes (#2308)
8fc2dc4c is described below
commit 8fc2dc4cec2b86e273bb319e1cf4fab5732782a6
Author: xiaobiaozhao <[email protected]>
AuthorDate: Tue Jun 4 11:32:18 2024 +0800
perf: Set async_io default value to yes (#2308)
Co-authored-by: hulk <[email protected]>
---
kvrocks.conf | 4 ++--
src/config/config.cc | 2 +-
tests/gocase/unit/type/hash/hash_test.go | 41 ++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/kvrocks.conf b/kvrocks.conf
index e7009e44..113344de 100644
--- a/kvrocks.conf
+++ b/kvrocks.conf
@@ -881,8 +881,8 @@ rocksdb.max_bytes_for_level_multiplier 10
# In iterators, it will prefetch data asynchronously in the background for
each file being iterated on.
# In MultiGet, it will read the necessary data blocks from those files in
parallel as much as possible.
-# Default no
-rocksdb.read_options.async_io no
+# Default yes
+rocksdb.read_options.async_io yes
# If yes, the write will be flushed from the operating system
# buffer cache before the write is considered complete.
diff --git a/src/config/config.cc b/src/config/config.cc
index 4139dfc6..3163dd97 100644
--- a/src/config/config.cc
+++ b/src/config/config.cc
@@ -251,7 +251,7 @@ Config::Config() {
new YesNoField(&rocks_db.write_options.memtable_insert_hint_per_batch,
false)},
/* rocksdb read options */
- {"rocksdb.read_options.async_io", false, new
YesNoField(&rocks_db.read_options.async_io, false)},
+ {"rocksdb.read_options.async_io", false, new
YesNoField(&rocks_db.read_options.async_io, true)},
};
for (auto &wrapper : fields) {
auto &field = wrapper.field;
diff --git a/tests/gocase/unit/type/hash/hash_test.go
b/tests/gocase/unit/type/hash/hash_test.go
index 38b0a576..3c769649 100644
--- a/tests/gocase/unit/type/hash/hash_test.go
+++ b/tests/gocase/unit/type/hash/hash_test.go
@@ -895,3 +895,44 @@ func TestHashWithAsyncIOEnabled(t *testing.T) {
require.Len(t, rdb.HVals(ctx, testKey).Val(), 50)
})
}
+
+func TestHashWithAsyncIODisabled(t *testing.T) {
+ srv := util.StartServer(t, map[string]string{
+ "rocksdb.read_options.async_io": "no",
+ })
+ defer srv.Close()
+
+ rdb := srv.NewClient()
+ defer func() { require.NoError(t, rdb.Close()) }()
+
+ ctx := context.Background()
+
+ t.Run("Test bug with large value after compaction", func(t *testing.T) {
+ testKey := "test-hash-1"
+ require.NoError(t, rdb.Del(ctx, testKey).Err())
+
+ src := rand.NewSource(time.Now().UnixNano())
+ dd := make([]byte, 5000)
+ for i := 1; i <= 50; i++ {
+ for j := range dd {
+ dd[j] = byte(src.Int63())
+ }
+ key := util.RandString(10, 20, util.Alpha)
+ require.NoError(t, rdb.HSet(ctx, testKey, key,
string(dd)).Err())
+ }
+
+ require.EqualValues(t, 50, rdb.HLen(ctx, testKey).Val())
+ require.Len(t, rdb.HGetAll(ctx, testKey).Val(), 50)
+ require.Len(t, rdb.HKeys(ctx, testKey).Val(), 50)
+ require.Len(t, rdb.HVals(ctx, testKey).Val(), 50)
+
+ require.NoError(t, rdb.Do(ctx, "COMPACT").Err())
+
+ time.Sleep(5 * time.Second)
+
+ require.EqualValues(t, 50, rdb.HLen(ctx, testKey).Val())
+ require.Len(t, rdb.HGetAll(ctx, testKey).Val(), 50)
+ require.Len(t, rdb.HKeys(ctx, testKey).Val(), 50)
+ require.Len(t, rdb.HVals(ctx, testKey).Val(), 50)
+ })
+}