Skip to content

Commit 5836973

Browse files
authored
Merge branch 'master' into avoidDeleteFailure
2 parents 1f3c932 + 9324c0c commit 5836973

37 files changed

+1461
-530
lines changed

.devcontainer/devcontainer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
}
3333
},
3434
"containerEnv": {
35-
"RONDB_PATH": "/usr/src/app/rondb-22.10.5-linux-glibc2.28-arm64_v8",
35+
"RONDB_PATH": "/usr/src/app/rondb-24.10.0-linux-glibc2.28-arm64_v8",
3636
// This assumes that the RonDB tarball is placed the root of the workspace folder
37-
"LD_LIBRARY_PATH": "/usr/src/app/rondb-22.10.5-linux-glibc2.28-arm64_v8/lib"
37+
"LD_LIBRARY_PATH": "/usr/src/app/rondb-24.10.0-linux-glibc2.28-arm64_v8/lib"
3838
}
3939
}

.github/workflows/build_test_push.yaml

+30-16
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ jobs:
1616

1717
- run: brew install protobuf
1818

19-
- name: Build
19+
- name: Build Slash
20+
run: cd pink/third/slash/slash && make
21+
22+
- name: Build Pink
2023
run: cd pink && make static_lib
2124

2225
build-and-run-redis-benchmark:
2326
needs: [build-pink-macos]
2427
runs-on: ubuntu-latest
2528
env:
26-
RONDB_TARBALL_URI: https://repo.hops.works/master/rondb-22.10.5-linux-glibc2.28-x86_64.tar.gz
29+
RONDB_VERSION: 24.10.0
30+
RONDB_TARBALL_URI: https://repo.hops.works/master/rondb-24.10.0-linux-glibc2.28-x86_64.tar.gz
31+
RONDB_DOCKER_DIR: /tmp/rondb-docker
32+
RONDB_TARBALL_FILE: rondb.tar.gz
2733
RONDB_PATH: /tmp/rondb
2834
IMAGE_NAME: rondis:latest
2935
CONTAINER_NAME: rondis
@@ -35,31 +41,33 @@ jobs:
3541
with:
3642
fetch-depth: 0
3743

44+
- name: Clone rondb-docker
45+
run: git clone -b release-0.7 https://github.com/logicalclocks/rondb-docker.git $RONDB_DOCKER_DIR
46+
47+
- name: Download RonDB
48+
run: |
49+
wget $RONDB_TARBALL_URI -O $RONDB_DOCKER_DIR/$RONDB_TARBALL_FILE
50+
mkdir -p $RONDB_PATH
51+
tar xfz $RONDB_DOCKER_DIR/$RONDB_TARBALL_FILE -C $RONDB_PATH --strip-components=1
52+
3853
- name: Run rondb-docker
39-
env:
40-
RONDB_DOCKER_DIR: /tmp/rondb-docker
4154
run: |
42-
path_now=$(pwd)
43-
git clone -b release-0.7 https://github.com/logicalclocks/rondb-docker.git $RONDB_DOCKER_DIR
44-
cd $RONDB_DOCKER_DIR && ./build_run_docker.sh -d \
55+
cd $RONDB_DOCKER_DIR
56+
# The script expects a relative path to the tarball
57+
./build_run_docker.sh -d \
58+
--rondb-tarball-path ./$RONDB_TARBALL_FILE \
59+
--rondb-version $RONDB_VERSION \
4560
--size small \
4661
--num-mgm-nodes 1 \
4762
--node-groups 1 \
4863
--replication-factor 1 \
4964
--num-mysql-nodes 1 \
5065
--num-rest-api-nodes 0 \
5166
--num-benchmarking-nodes 0
52-
cd $path_now
5367
5468
- name: Build Rondis image
5569
run: docker build -t $IMAGE_NAME .
5670

57-
- name: Download RonDB
58-
run: |
59-
wget $RONDB_TARBALL_URI -O /tmp/temp_tarball.tar.gz
60-
mkdir -p $RONDB_PATH
61-
tar xfz /tmp/temp_tarball.tar.gz -C $RONDB_PATH --strip-components=1
62-
6371
- name: Create Rondis environment
6472
run: |
6573
docker run -d \
@@ -79,7 +87,7 @@ jobs:
7987
run: |
8088
docker exec -i mysqld_1 bash -c "mysql -uroot -e 'CREATE DATABASE redis;'"
8189
for sql_file in pink/rondis/sql/*.sql; do
82-
cat "$sql_file" | docker exec -i mysqld_1 mysql -uroot
90+
cat "$sql_file" | docker exec -i mysqld_1 mysql -uroot --database=redis
8391
done
8492
8593
- name: Connect Docker network
@@ -93,17 +101,23 @@ jobs:
93101
docker exec -w $DOCKER_WORK_DIR -e LD_LIBRARY_PATH=/tmp/rondb/lib \
94102
-t $CONTAINER_NAME pink/rondis/rondis 6379 mgmd_1:1186 2 > $LOCAL_RONDIS_LOG &
95103
104+
# Takes a few seconds before all connections are setup and started properly
105+
- name: Wait for Rondis server to start properly
106+
run: sleep 5
107+
96108
# Running this multiple times to check for memory leaks and that overwrites/updates/deletes work
97109
- name: Run tests multiple times
98110
run: |
99111
for i in {1..50}; do
100112
docker exec -w $DOCKER_WORK_DIR -i $CONTAINER_NAME bash -c \
101113
"pink/rondis/tests/get_set.sh $((i % 3))"
114+
docker exec -w $DOCKER_WORK_DIR -i $CONTAINER_NAME bash -c \
115+
"pink/rondis/tests/hget_hset.sh $((i % 5)) $((i % 3))"
102116
echo "Success in run $i"
103117
done
104118
105119
- name: Run Redis benchmark
106-
run: docker exec -i $CONTAINER_NAME bash -c "redis-benchmark -t get,set -c 2"
120+
run: docker exec -i $CONTAINER_NAME bash -c "redis-benchmark -t get,set,incr,hget,hset,hincr -r 100 -P 10 --threads 3"
107121

108122
- name: Show Rondis logs
109123
if: always()

pink/Makefile

+1-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ ifeq ($(NO_PB),1)
6363
$(filter-out $(VERSION_CC) $(wildcard $(SRC_DIR)/pb_*), $(wildcard $(SRC_DIR)/*.cc))
6464
endif
6565

66-
67-
ifndef SLASH_PATH
68-
$(warning Warning: missing slash path, using default)
69-
SLASH_PATH=$(CURDIR)/third/slash
70-
endif
66+
SLASH_PATH=$(CURDIR)/third/slash
7167
SLASH_INCLUDE_DIR=$(SLASH_PATH)
7268
SLASH_LIBRARY=$(SLASH_PATH)/slash/lib/libslash.a
7369

pink/include/pink_conn.h

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class PinkConn : public std::enable_shared_from_this<PinkConn> {
8181
}
8282

8383
bool IsClose() { return close_; }
84+
// This can be used by the application
8485
void SetClose(bool close) { close_ = close; }
8586

8687
void set_last_interaction(const struct timeval &now) {

pink/include/redis_conn.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class RedisConn: public PinkConn {
3434
const int rbuf_max_len = REDIS_MAX_MESSAGE);
3535
virtual ~RedisConn();
3636

37-
virtual ReadStatus GetRequest();
38-
virtual WriteStatus SendReply();
39-
virtual int WriteResp(const std::string& resp);
37+
virtual ReadStatus GetRequest() override;
38+
virtual WriteStatus SendReply() override;
39+
virtual int WriteResp(const std::string& resp) override;
4040

4141
void TryResizeBuffer() override;
4242
void SetHandleType(const HandleType& handle_type);

pink/rondis/Makefile

+2-5
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ endif
1414

1515
all: rondis
1616

17-
ifndef PINK_PATH
18-
$(warning Warning: missing pink path, using default)
19-
PINK_PATH=$(CURDIR)/../..
20-
endif
17+
PINK_PATH=$(CURDIR)/../..
2118
PINK_INCLUDE_DIR=$(PINK_PATH)
2219
PINK_LIBRARY=$(PINK_PATH)/pink/lib/libpink.a
2320

@@ -48,7 +45,7 @@ endif
4845
LDFLAGS := $(DEP_LIBS) $(LDFLAGS)
4946

5047
# Use find to locate all .cc files in subdirectories
51-
SOURCES = $(CURDIR)/rondis.cc $(CURDIR)/rondb.cc $(CURDIR)/common.cc $(CURDIR)/string/table_definitions.cc $(CURDIR)/string/commands.cc $(CURDIR)/string/db_operations.cc
48+
SOURCES = $(CURDIR)/rondis.cc $(CURDIR)/rondb.cc $(CURDIR)/common.cc $(CURDIR)/string/table_definitions.cc $(CURDIR)/string/commands.cc $(CURDIR)/string/db_operations.cc $(CURDIR)/string/interpreted_code.cc
5249
OBJECTS = $(SOURCES:.cc=.o)
5350

5451
# Target to build the executable "rondis"

pink/rondis/common.cc

+18-28
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,13 @@
55

66
#include "common.h"
77

8-
/**
9-
* @brief Writes formatted data to a buffer.
10-
*
11-
* This function writes formatted data to the provided buffer using a format string
12-
* and a variable number of arguments, similar to printf. It ensures that the
13-
* formatted string does not exceed the specified buffer size.
14-
*
15-
* @param buffer A pointer to the buffer where the formatted string will be written.
16-
* @param bufferSize The size of the buffer.
17-
* @param format A format string that specifies how subsequent arguments are converted for output.
18-
* @param ... Additional arguments specifying the data to be formatted.
19-
* @return The number of characters written, excluding the null terminator. If the output
20-
* is truncated due to the buffer size limit, the return value is the number of
21-
* characters (excluding the null terminator) which would have been written if
22-
* enough space had been available.
23-
*/
24-
int write_formatted(char *buffer, int bufferSize, const char *format, ...)
25-
{
26-
int len = 0;
27-
va_list arguments;
28-
va_start(arguments, format);
29-
len = vsnprintf(buffer, bufferSize, format, arguments);
30-
va_end(arguments);
31-
return len;
32-
}
33-
348
void assign_ndb_err_to_response(
359
std::string *response,
3610
const char *app_str,
3711
NdbError error)
3812
{
3913
char buf[512];
40-
write_formatted(buf, sizeof(buf), "-ERR %s; NDB(%u) %s\r\n", app_str, error.code, error.message);
14+
snprintf(buf, sizeof(buf), "-ERR %s; NDB(%u) %s\r\n", app_str, error.code, error.message);
4115
std::cout << buf;
4216
response->assign(buf);
4317
}
@@ -47,7 +21,23 @@ void assign_generic_err_to_response(
4721
const char *app_str)
4822
{
4923
char buf[512];
50-
write_formatted(buf, sizeof(buf), "-ERR %s\r\n", app_str);
24+
snprintf(buf, sizeof(buf), "-ERR %s\r\n", app_str);
5125
std::cout << buf;
5226
response->assign(buf);
5327
}
28+
29+
void set_length(char *buf, Uint32 key_len)
30+
{
31+
Uint8 *ptr = (Uint8 *)buf;
32+
ptr[0] = (Uint8)(key_len & 255);
33+
ptr[1] = (Uint8)(key_len >> 8);
34+
}
35+
36+
Uint32 get_length(char *buf)
37+
{
38+
Uint8 *ptr = (Uint8 *)buf;
39+
Uint8 low = ptr[0];
40+
Uint8 high = ptr[1];
41+
Uint32 len32 = Uint32(low) + Uint32(256) * Uint32(high);
42+
return len32;
43+
}

pink/rondis/common.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
#include <ndbapi/NdbApi.hpp>
22
#include <ndbapi/Ndb.hpp>
33

4+
#ifndef RONDIS_COMMON_H
5+
#define RONDIS_COMMON_H
6+
47
#define MAX_CONNECTIONS 2
58

69
#define REDIS_DB_NAME "redis"
710

8-
#define FOREIGN_KEY_RESTRICT_ERROR 256
11+
#define RESTRICT_VALUE_ROWS_ERROR 6000
912

1013
#define RONDB_INTERNAL_ERROR 2
1114
#define READ_ERROR 626
1215

1316
int write_formatted(char *buffer, int bufferSize, const char *format, ...);
1417
void assign_ndb_err_to_response(std::string *response, const char *app_str, NdbError error);
1518
void assign_generic_err_to_response(std::string *response, const char *app_str);
19+
void set_length(char* buf, Uint32 key_len);
20+
Uint32 get_length(char* buf);
1621

1722
// NDB API error messages
1823
#define FAILED_GET_DICT "Failed to get NdbDict"
1924
#define FAILED_CREATE_TABLE_OBJECT "Failed to create table object"
2025
#define FAILED_CREATE_TXN_OBJECT "Failed to create transaction object"
2126
#define FAILED_EXEC_TXN "Failed to execute transaction"
2227
#define FAILED_READ_KEY "Failed to read key"
28+
#define FAILED_INCR_KEY "Failed to increment key"
29+
#define FAILED_HSET_KEY "Failed to find key"
30+
#define FAILED_INCR_KEY_MULTI_ROW "Failed to increment key, multi-row value"
2331
#define FAILED_GET_OP "Failed to get NdbOperation object"
2432
#define FAILED_DEFINE_OP "Failed to define RonDB operation"
2533

@@ -28,3 +36,4 @@ void assign_generic_err_to_response(std::string *response, const char *app_str);
2836
#define REDIS_WRONG_NUMBER_OF_ARGS "wrong number of arguments for '%s' command"
2937
#define REDIS_NO_SUCH_KEY "$-1\r\n"
3038
#define REDIS_KEY_TOO_LARGE "key is too large (3000 bytes max)"
39+
#endif

0 commit comments

Comments
 (0)