Skip to content

Commit 45c1b78

Browse files
committed
DNM: debug unit test
Signed-off-by: Abhijat Malviya <[email protected]>
1 parent eff84ff commit 45c1b78

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: single-unit
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- abhijat/dnm/debug-test
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
pre-commit:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
with:
19+
fetch-depth: 2
20+
build:
21+
strategy:
22+
matrix:
23+
include:
24+
- container: "ubuntu-dev:24"
25+
build-type: Debug
26+
compiler: { cxx: clang++, c: clang }
27+
# https://maskray.me/blog/2023-08-25-clang-wunused-command-line-argument (search for compiler-rt)
28+
cxx_flags: "-Wno-error=unused-command-line-argument"
29+
sanitizers: "Sanitizers"
30+
31+
runs-on: ubuntu-latest
32+
container:
33+
image: ghcr.io/romange/${{ matrix.container }}
34+
# Seems that docker by default prohibits running iouring syscalls
35+
options: --security-opt seccomp=unconfined --sysctl "net.ipv6.conf.all.disable_ipv6=0"
36+
volumes:
37+
- /:/hostroot
38+
- /mnt:/mnt
39+
credentials:
40+
username: ${{ github.repository_owner }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
steps:
44+
- uses: actions/checkout@v6
45+
with:
46+
submodules: true
47+
48+
- name: Prepare Environment
49+
run: |
50+
uname -a
51+
mkdir -p ${GITHUB_WORKSPACE}/build
52+
53+
echo "===================Before freeing up space ============================================"
54+
df -h
55+
rm -rf /hostroot/usr/share/dotnet
56+
rm -rf /hostroot/usr/local/share/boost
57+
rm -rf /hostroot/usr/local/lib/android
58+
rm -rf /hostroot/opt/ghc
59+
echo "===================After freeing up space ============================================"
60+
touch /mnt/foo
61+
ls -la /mnt/foo
62+
63+
- name: Configure CMake
64+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
65+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
66+
run: |
67+
echo "ulimit is"
68+
ulimit -s
69+
echo "-----------------------------"
70+
echo "disk space is:"
71+
df -h
72+
echo "-----------------------------"
73+
74+
echo "ASAN/USAN"
75+
export ASAN="ON"
76+
export USAN="ON"
77+
78+
cmake -B ${GITHUB_WORKSPACE}/build \
79+
-DCMAKE_BUILD_TYPE=${{matrix.build-type}} \
80+
-DWITH_AWS=OFF \
81+
-DWITH_GCP=OFF \
82+
-DWITH_UNWIND=OFF \
83+
-DWITH_GPERF=OFF \
84+
-GNinja \
85+
-DCMAKE_C_COMPILER="${{matrix.compiler.c}}" \
86+
-DCMAKE_CXX_COMPILER="${{matrix.compiler.cxx}}" \
87+
-DCMAKE_CXX_FLAGS="${{matrix.cxx_flags}}" -DWITH_AWS:BOOL=OFF \
88+
-DWITH_ASAN="${ASAN}" \
89+
-DWITH_USAN="${USAN}" \
90+
-L
91+
92+
cd ${GITHUB_WORKSPACE}/build && pwd
93+
94+
- name: Build
95+
run: |
96+
cd ${GITHUB_WORKSPACE}/build
97+
ninja hll_family_test
98+
99+
- name: C++ Unit Tests - Epoll
100+
run: |
101+
cd ${GITHUB_WORKSPACE}/build
102+
GLOG_alsologtostderr=1 FLAGS_fiber_safety_margin=4096 FLAGS_force_epoll=true GLOG_vmodule=rdb_load=1,rdb_save=1,snapshot=1 \
103+
timeout 30m ./hll_family_test --gtest_repeat=100 --gtest_break_on_failure
104+
105+
- name: C++ Unit Tests - IoUring
106+
run: |
107+
cd ${GITHUB_WORKSPACE}/build
108+
GLOG_alsologtostderr=1 GLOG_vmodule=rdb_load=1,rdb_save=1,snapshot=1,op_manager=1,op_manager_test=1 \
109+
FLAGS_fiber_safety_margin=4096 timeout 30m ./hll_family_test --gtest_repeat=100 --gtest_break_on_failure
110+
111+
- name: Upload unit logs on failure
112+
if: failure()
113+
uses: actions/upload-artifact@v6
114+
with:
115+
name: unit_logs
116+
path: /tmp/*INFO*

src/server/test_utils.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ void BaseFamilyTest::ResetService() {
304304
}
305305

306306
LOG(ERROR) << "Transaction for shard " << es->shard_id();
307+
std::unique_lock conn_lock{mu_};
307308
for (auto& conn : connections_) {
308309
auto* context = conn.second->cmd_cntx();
309310
if (context->transaction && context->transaction->IsActive(es->shard_id())) {

src/server/transaction.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,13 @@ pair<uint16_t, bool> Transaction::DisarmInShardWhen(ShardId sid, uint16_t releva
11001100
}
11011101

11021102
bool Transaction::IsActive(ShardId sid) const {
1103+
if (shard_data_.empty()) {
1104+
return false;
1105+
}
1106+
1107+
DCHECK(!shard_data_.empty()) << "IsActive: shard_data_ empty, sid=" << sid
1108+
<< ", unique_shard_cnt_=" << unique_shard_cnt_ << ", name=" << Name()
1109+
<< ", txid=" << txid_;
11031110
// If we have only one shard, we often don't store infromation about all shards, so determine it
11041111
// solely by id
11051112
if (unique_shard_cnt_ == 1) {

src/server/transaction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ class Transaction {
558558
}
559559

560560
unsigned SidToId(ShardId sid) const {
561+
DCHECK(!shard_data_.empty()) << "SidToId: shard_data_ empty, sid=" << sid
562+
<< ", unique_shard_cnt_=" << unique_shard_cnt_
563+
<< ", name=" << Name() << ", txid=" << txid_;
561564
return sid < shard_data_.size() ? sid : 0;
562565
}
563566

0 commit comments

Comments
 (0)