Skip to content

Commit

Permalink
Merge branch 'unstable' into unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin authored Sep 1, 2024
2 parents da72c4f + 6c85004 commit 18317ba
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/kvrocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ jobs:
- name: Rocky Linux 9
image: rockylinux:9
compiler: gcc
- name: Debian 12
image: debian:12
compiler: gcc

runs-on: ubuntu-22.04
container:
Expand Down Expand Up @@ -474,6 +477,13 @@ jobs:
update-alternatives --install /usr/bin/c++ c++ /opt/rh/gcc-toolset-12/root/usr/bin/g++ 100
echo "NPROC=$(nproc)" >> $GITHUB_ENV
- name: Setup Debian 12
if: ${{ startsWith(matrix.image, 'debian') }}
run: |
apt update
apt install -y bash build-essential cmake curl git libssl-dev libtool python3 python3-pip wget
echo "NPROC=$(nproc)" >> $GITHUB_ENV
- name: Cache redis
id: cache-redis
uses: actions/cache@v3
Expand All @@ -492,6 +502,7 @@ jobs:

- name: Install redis
if: ${{ steps.cache-redis.outputs.cache-hit != 'true' || steps.cache-redis-server.outputs.cache-hit != 'true' }}
shell: bash
run: |
curl -O https://download.redis.io/releases/redis-6.2.14.tar.gz
tar -xzvf redis-6.2.14.tar.gz
Expand Down Expand Up @@ -520,11 +531,16 @@ jobs:
GOCASE_RUN_ARGS=""
./x.py test go build $GOCASE_RUN_ARGS
- name: Install redis-py
if: ${{ !startsWith(matrix.image, 'archlinux') }} # already installed
- name: Install redis-py for openSUSE and Rocky
if: ${{ !startsWith(matrix.image, 'archlinux') && !startsWith(matrix.image, 'debian') }}
run: pip3 install redis==4.3.6

- name: Install redis-py for Debian
if: ${{ startsWith(matrix.image, 'debian') }}
run: apt install -y python3-redis

- name: Run kvrocks2redis Test
shell: bash
run: |
$HOME/local/bin/redis-server --daemonize yes
mkdir -p kvrocks2redis-ci-data
Expand Down
14 changes: 14 additions & 0 deletions kvrocks.conf
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,20 @@ json-max-nesting-depth 1024
# Default: json
json-storage-format json

# Whether to enable transactional mode engine::Context.
#
# If enabled, is_txn_mode in engine::Context will be set properly,
# which is expected to improve the consistency of commands.
# If disabled, is_txn_mode in engine::Context will be set to false,
# making engine::Context equivalent to engine::Storage.
#
# NOTE: This is an experimental feature. If you find errors, performance degradation,
# excessive memory usage, excessive disk I/O, etc. after enabling it, please try disabling it.
# At the same time, we welcome feedback on related issues to help iterative improvements.
#
# Default: no
txn-context-enabled no

################################## TLS ###################################

# By default, TLS/SSL is disabled, i.e. `tls-port` is set to 0.
Expand Down
1 change: 1 addition & 0 deletions src/config/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Config::Config() {
{"json-max-nesting-depth", false, new IntField(&json_max_nesting_depth, 1024, 0, INT_MAX)},
{"json-storage-format", false,
new EnumField<JsonStorageFormat>(&json_storage_format, json_storage_formats, JsonStorageFormat::JSON)},
{"txn-context-enabled", true, new YesNoField(&txn_context_enabled, false)},

/* rocksdb options */
{"rocksdb.compression", false,
Expand Down
3 changes: 3 additions & 0 deletions src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ struct Config {
int json_max_nesting_depth = 1024;
JsonStorageFormat json_storage_format = JsonStorageFormat::JSON;

// Enable transactional mode in engine::Context
bool txn_context_enabled = false;

struct RocksDB {
int block_size;
bool cache_index_and_filter_blocks;
Expand Down
7 changes: 6 additions & 1 deletion src/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ struct Context {
std::unique_ptr<rocksdb::WriteBatchWithIndex> batch = nullptr;

/// is_txn_mode is used to determine whether the current Context is in transactional mode,
/// if it is not transactional mode, then Context is equivalent to a Storage
/// if it is not transactional mode, then Context is equivalent to a Storage.
/// If the configuration of txn-context-enabled is no, it is false.
bool is_txn_mode = true;

/// NoTransactionContext returns a Context with a is_txn_mode of false
Expand All @@ -409,6 +410,10 @@ struct Context {
/// TODO: Change it to defer getting the context, and the snapshot is pinned after the first read operation
explicit Context(engine::Storage *storage) : storage(storage) {
auto guard = storage->ReadLockGuard();
if (!storage->GetConfig()->txn_context_enabled) {
is_txn_mode = false;
return;
}
snapshot = storage->GetDB()->GetSnapshot(); // NOLINT
}
~Context() {
Expand Down

0 comments on commit 18317ba

Please sign in to comment.