Skip to content

Commit 6044f8b

Browse files
author
wuxianrong
committed
The data backup and recovery functions have been added
1 parent 3e19283 commit 6044f8b

27 files changed

Lines changed: 2246 additions & 271 deletions

.github/workflows/pika.yml

Lines changed: 56 additions & 242 deletions
Original file line numberDiff line numberDiff line change
@@ -16,261 +16,75 @@ jobs:
1616
# The CMake configure and build commands are platform-agnostic and should work equally well on Windows or Mac.
1717
# You can convert this to a matrix build if you need cross-platform coverage.
1818
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
19-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-22.04
2020

2121
steps:
22-
- name: Free Disk Space (Ubuntu Host)
23-
run: |
24-
sudo rm -rf /usr/share/dotnet
25-
sudo rm -rf /usr/local/lib/android
26-
sudo rm -rf /opt/ghc
27-
sudo rm -rf /opt/hostedtoolcache/CodeQL
28-
sudo docker system prune -af
2922
- uses: actions/checkout@v4
3023

31-
- name: Set up Go
32-
uses: actions/setup-go@v5
33-
with:
34-
go-version: 1.19
35-
36-
- name: ccache
37-
uses: hendrikmuhs/[email protected]
38-
with:
39-
key: ubuntu-latest
40-
41-
- name: Install Deps
24+
- name: Build Docker image
4225
run: |
43-
sudo apt-get update
44-
sudo apt-get install -y autoconf libprotobuf-dev protobuf-compiler clang-tidy
45-
46-
- name: Configure CMake
47-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
48-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
49-
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
26+
docker build -t pika-ci -f ci/Dockerfile .
5027
51-
- name: Build
52-
# Build your program with the given configuration
53-
run: cmake --build build --config ${{ env.BUILD_TYPE }}
54-
55-
- name: Cleanup
28+
- name: Build Pika (inside Docker)
5629
run: |
57-
rm -rf ./buildtrees
30+
docker run --rm \
31+
-v ${{ github.workspace }}:/work \
32+
-w /work \
33+
pika-ci \
34+
bash -c "
35+
rm -rf build buildtrees &&
36+
cmake -B build \
37+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
38+
-DUSE_PIKA_TOOLS=ON &&
39+
cmake --build build -j$(nproc)
40+
"
5841
59-
- uses: actions/upload-artifact@v4
60-
with:
61-
name: ${{ env.ARTIFACT_PIKA_NAME }}
62-
path: ${{ github.workspace }}/build/pika
63-
64-
- name: Test
65-
working-directory: ${{ github.workspace }}/build
66-
# Execute tests defined by the CMake configuration.
67-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
68-
run: ctest -C ${{ env.BUILD_TYPE }}
69-
70-
- name: Unit Test
71-
working-directory: ${{ github.workspace }}
72-
run: ./pikatests.sh all clean
73-
74-
# master on port 9221, slave on port 9231, all with 2 db
75-
- name: Start codis, pika master and pika slave
76-
working-directory: ${{ github.workspace }}/build
42+
- name: Run CTest (inside Docker)
7743
run: |
78-
chmod +x ../tests/integration/start_master_and_slave.sh
79-
../tests/integration/start_master_and_slave.sh
80-
chmod +x ../tests/integration/start_codis.sh
81-
../tests/integration/start_codis.sh
44+
docker run --rm \
45+
-v ${{ github.workspace }}:/work \
46+
-w /work/build \
47+
pika-ci \
48+
ctest --output-on-failure
8249
83-
- name: Run Go E2E Tests
84-
working-directory: ${{ github.workspace }}/build
50+
- name: Unit Test
8551
run: |
86-
cd ../tools/pika_keys_analysis/
87-
go test -v ./...
88-
cd ../../tests/integration/
89-
chmod +x integrate_test.sh
90-
sh integrate_test.sh
91-
52+
docker run --rm \
53+
-v ${{ github.workspace }}:/work \
54+
-w /work \
55+
pika-ci \
56+
bash -c "./pikatests.sh all clean"
57+
9258
build_on_rocky:
93-
runs-on: ubuntu-latest
94-
container:
95-
image: rockylinux:9
96-
59+
runs-on: ubuntu-22.04
9760
steps:
98-
- name: set up mirror
99-
run: |
100-
rm -rf /etc/yum.repos.d/CentOS-Base.repo
101-
cat > /etc/yum.repos.d/CentOS-Base.repo << EOL
102-
[base]
103-
name=CentOS-\$releasever - Base
104-
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/\$basearch/
105-
gpgcheck=1
106-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
107-
108-
[updates]
109-
name=CentOS-\$releasever - Updates
110-
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/updates/\$basearch/
111-
gpgcheck=1
112-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
113-
114-
[extras]
115-
name=CentOS-\$releasever - Extras
116-
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/extras/\$basearch/
117-
gpgcheck=1
118-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
119-
120-
[centosplus]
121-
name=CentOS-\$releasever - Plus
122-
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/centosplus/\$basearch/
123-
gpgcheck=1
124-
enabled=0
125-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
126-
EOL
127-
128-
cat > /etc/yum.repos.d/CentOS-SCLo-scl.repo << EOL
129-
[centos-sclo-sclo]
130-
name=CentOS-7 - SCLo sclo
131-
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
132-
gpgcheck=1
133-
enabled=1
134-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
135-
136-
[centos-sclo-sclo-source]
137-
name=CentOS-7 - SCLo sclo Source
138-
baseurl=https://mirrors.aliyun.com/centos/7/sclo/Source/sclo/
139-
gpgcheck=1
140-
enabled=0
141-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
142-
EOL
143-
144-
cat > /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo << EOL
145-
[centos-sclo-rh]
146-
name=CentOS-7 - SCLo rh
147-
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
148-
gpgcheck=1
149-
enabled=1
150-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
151-
152-
[centos-sclo-rh-source]
153-
name=CentOS-7 - SCLo rh Source
154-
baseurl=https://mirrors.aliyun.com/centos/7/sclo/Source/rh/
155-
gpgcheck=1
156-
enabled=0
157-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
158-
EOL
159-
160-
rpm --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-7
161-
rpm --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-SCLo
162-
163-
yum clean all
164-
yum makecache
165-
166-
- name: Install deps
167-
run: |
168-
dnf update -y
169-
dnf install -y bash cmake wget git autoconf gcc perl-Digest-SHA tcl which tar g++ tar epel-release gcc-c++ libstdc++-devel gcc-toolset-13 binutils
170-
dnf clean all
171-
rm -rf /var/cache/dnf
172-
173-
- name: Set up Go
174-
uses: actions/setup-go@v5
175-
with:
176-
go-version: 1.19
177-
178-
- name: Checkout
179-
uses: actions/checkout@v4
180-
with:
181-
fetch-depth: 1
182-
183-
- name: Configure CMake
184-
run: |
185-
source /opt/rh/gcc-toolset-13/enable
186-
cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address .
187-
188-
- uses: actions/cache@v3
189-
with:
190-
path: ${{ github.workspace }}/deps
191-
key: ${{ runner.os }}-rocky-deps-${{ hashFiles('**/CMakeLists.txt') }}
192-
193-
- uses: actions/cache@v3
194-
with:
195-
path: ${{ github.workspace }}/buildtrees
196-
key: ${{ runner.os }}-rocky-buildtrees-${{ hashFiles('**/CMakeLists.txt') }}
197-
198-
- name: Build
199-
run: |
200-
source /opt/rh/gcc-toolset-13/enable
201-
cmake --build build --config ${{ env.BUILD_TYPE }}
202-
203-
- name: Cleanup
204-
run: |
205-
rm -rf ./buildtrees
206-
rm -rf ./build/Testing
207-
rm -rf ./deps/src ./deps/include ./deps/share
208-
209-
echo "Cleaning up object files to save space..."
210-
find ./build -name "*.o" -type f -delete
211-
find ./build -name "*.a" -type f -delete
212-
find ./build -name "*.pb.cc" -type f -delete
213-
find ./build -name "*.pb.h" -type f -delete
214-
215-
echo "Stripping debug symbols from binaries..."
216-
find ./build -type f -executable -not -name "*.sh" -exec strip --strip-debug {} \; || true
217-
rm -rf .git
218-
rm -rf include
219-
rm -rf docs
220-
rm -rf tools/codis_to_pika tools/aof_to_pika tools/binlog_sender
221-
rm -rf codis/ansible codis/example codis/doc
222-
223-
- name: Test
224-
working-directory: ${{ github.workspace }}/build
225-
run: ctest -C ${{ env.BUILD_TYPE }}
226-
227-
- name: Unit Test
228-
working-directory: ${{ github.workspace }}
229-
run: ./pikatests.sh all clean
230-
231-
- name: Cleanup artifacts
232-
working-directory: ${{ github.workspace }}/build
233-
run: |
234-
df -h
235-
rm -rf Testing CMakeFiles CMakeCache.txt cmake_install.cmake Makefile
236-
find . -name "*.o" -o -name "*.a" -delete
237-
find . -name "*.log" -delete
238-
find . -name "*.cmake" -delete
239-
find . -type d -name "CMakeFiles" -exec rm -rf {} + || true
240-
find . -name "*.pb.cc" -o -name "*.pb.h" -delete || true
241-
find . -type f -name "*_test" -executable -delete || true
242-
find ./src/storage/tests -type f -perm -111 -delete || true
243-
find ../deps -name "*.a" -delete
244-
245-
go clean -cache -testcache -modcache
246-
rm -rf /root/.cache/go-build /root/go/pkg/mod
247-
rm -rf ../log ../pika_log ../dump ../*.log ../dbsync ../db[0-9]* ../log[0-9]*
248-
find ../src -name "*.o" -delete || true
249-
dnf clean all
250-
rm -rf /var/cache/dnf /tmp/* /var/tmp/*
251-
du -h --max-depth=3 .. | sort -hr | head -n 20
252-
find .. -type f -exec du -h {} + | sort -hr | head -n 20
253-
du -h --max-depth=1 / | sort -hr | head -n 15
254-
df -h
255-
256-
- name: Start codis, pika master and pika slave
257-
working-directory: ${{ github.workspace }}/build
258-
run: |
259-
chmod +x ../tests/integration/start_master_and_slave.sh
260-
../tests/integration/start_master_and_slave.sh
261-
chmod +x ../tests/integration/start_codis.sh
262-
../tests/integration/start_codis.sh
263-
264-
- name: Run Go E2E Tests
265-
working-directory: ${{ github.workspace }}/build
266-
run: |
267-
find . -name "pika.conf" -exec sed -i 's/loglevel : info/loglevel : error/g' {} +
268-
find . -name "pika.conf" -exec sed -i 's/loglevel : debug/loglevel : error/g' {} +
269-
cd ../tools/pika_keys_analysis/
270-
go test -v ./...
271-
cd ../../tests/integration/
272-
chmod +x integrate_test.sh
273-
sh integrate_test.sh
61+
- uses: actions/checkout@v4
62+
63+
- name: Build Docker image for Rocky CI
64+
run: |
65+
docker build -t pika-rocky-ci -f ci/Dockerfile .
66+
67+
- name: Run build inside container
68+
run: |
69+
docker run --rm \
70+
-v ${{ github.workspace }}:/work \
71+
-w /work \
72+
pika-rocky-ci \
73+
bash -c "rm -rf build buildtrees && cmake -B build -DCMAKE_BUILD_TYPE=Release -DUSE_PIKA_TOOLS=ON && cmake --build build -j2"
74+
- name: Run CTest (inside Docker)
75+
run: |
76+
docker run --rm \
77+
-v ${{ github.workspace }}:/work \
78+
-w /work/build \
79+
pika-ci \
80+
ctest --output-on-failure
81+
- name: Unit Test
82+
run: |
83+
docker run --rm \
84+
-v ${{ github.workspace }}:/work \
85+
-w /work \
86+
pika-ci \
87+
bash -c "./pikatests.sh all clean"
27488
27589
build_on_macos:
27690

CMakeLists.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ set(INSTALL_LIBDIR ${STAGED_INSTALL_PREFIX}/lib)
8989
set(INSTALL_LIBDIR_64 ${STAGED_INSTALL_PREFIX}/lib64)
9090
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${STAGED_INSTALL_PREFIX})
9191

92+
# Fix __const__ macro conflict with GCC 13+/glibc 2.38+ in existing brpc headers
93+
# This must run during CMake configuration to fix cached/existing headers
94+
if(EXISTS "${INSTALL_INCLUDEDIR}/butil/errno.h")
95+
file(READ "${INSTALL_INCLUDEDIR}/butil/errno.h" ERRNO_H_CONTENT)
96+
string(FIND "${ERRNO_H_CONTENT}" "#ifndef __const__" HAS_CONST_MACRO)
97+
if(NOT HAS_CONST_MACRO EQUAL -1)
98+
message(STATUS "Patching existing brpc errno.h for GCC 13+ compatibility")
99+
string(REPLACE "#ifndef __const__" "#if 0 /* disabled for GCC 13+ compatibility */" ERRNO_H_CONTENT "${ERRNO_H_CONTENT}")
100+
file(WRITE "${INSTALL_INCLUDEDIR}/butil/errno.h" "${ERRNO_H_CONTENT}")
101+
endif()
102+
endif()
103+
92104
execute_process(COMMAND sh ${CMAKE_UTILS_DIR}/Get_OS_Version.sh
93105
OUTPUT_VARIABLE OS_VERSION)
94106

@@ -664,6 +676,12 @@ ExternalProject_Add(brpc
664676
1
665677
UPDATE_COMMAND
666678
""
679+
# Patch to fix __const__ macro conflict with GCC 13+/glibc 2.38+
680+
# The issue is that brpc defines __const__ as __unused__ which conflicts with
681+
# glibc's __glibc_has_attribute(__const__) macro in sys/cdefs.h
682+
# We replace '#ifndef __const__' with '#if 0' to disable the problematic macro
683+
PATCH_COMMAND
684+
sh -c "sed -i.bak 's/#ifndef __const__/#if 0 /' src/butil/errno.h && cat src/butil/errno.h | head -35"
667685
LOG_CONFIGURE
668686
1
669687
LOG_BUILD
@@ -677,16 +695,29 @@ ExternalProject_Add(brpc
677695
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
678696
-DCMAKE_BUILD_TYPE=${LIB_BUILD_TYPE}
679697
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
698+
-DCMAKE_FIND_ROOT_PATH=${STAGED_INSTALL_PREFIX}
699+
-DCMAKE_INCLUDE_PATH=${INSTALL_INCLUDEDIR}
700+
-DCMAKE_LIBRARY_PATH=${INSTALL_LIBDIR}
680701
-DWITH_GLOG=ON
681702
-DWITH_SNAPPY=ON
682703
-DBUILD_SHARED_LIBS=OFF
683704
-DDOWNLOAD_GTEST=OFF
705+
-DCMAKE_EXE_LINKER_FLAGS=-L${INSTALL_LIBDIR}\ -L${INSTALL_LIBDIR_64}
684706
BUILD_ALWAYS
685707
1
686708
BUILD_COMMAND
687709
make -j${CPU_CORE}
688710
)
689711

712+
# Fix the installed header file after brpc installation
713+
# This is needed because braft uses the installed headers, not the patched source
714+
# The __const__ macro in butil/errno.h conflicts with glibc 2.38+ / GCC 13+
715+
ExternalProject_Add_Step(brpc fix_installed_headers
716+
COMMAND sh -c "sed -i.bak 's/#ifndef __const__/#if 0 /' ${INSTALL_INCLUDEDIR}/butil/errno.h && cat ${INSTALL_INCLUDEDIR}/butil/errno.h | head -35"
717+
DEPENDEES install
718+
COMMENT "Patching installed brpc headers for GCC 13+ compatibility"
719+
)
720+
690721
if(${OS_VERSION} MATCHES "Rocky" OR ${OS_VERSION} MATCHES "CentOS")
691722
set(BRPC_LIBRARY ${INSTALL_LIBDIR_64}/libbrpc.a)
692723
else()

0 commit comments

Comments
 (0)