Skip to content

SELECT does not wait for FREEZE + UPDATE #2805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Mar 19, 2025
Merged
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 41 additions & 31 deletions test/clt-tests/core/test-freeze-unfreeze-update.rec
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
––– input –––
echo -e "searchd {\n listen = 9315:mysql\n listen = 9316\n log = /tmp/searchd.log\n pid_file = /tmp/searchd.pid\n data_dir = /tmp/data\n watchdog = 0\n}" > /tmp/116.conf
echo -e "searchd {\n listen = 9306:mysql\n listen = 9316\n log = /tmp/searchd.log\n pid_file = /tmp/searchd.pid\n data_dir = /tmp/data\n watchdog = 0\n}" > /tmp/watchdog-off.conf
––– output –––
––– input –––
mkdir -p /tmp/data; rm -f /tmp/searchd.log; searchd --stopwait > /dev/null; searchd -c /tmp/116.conf; if timeout 10 grep -qm1 '\[BUDDY\] started' <(tail -n 1000 -f /tmp/searchd.log); then echo 'Buddy started!'; else echo 'Timeout or failed!'; cat /tmp/searchd.log;fi
mkdir -p /tmp/data; rm -f /tmp/searchd.log; searchd --stopwait > /dev/null; searchd -c /tmp/watchdog-off.conf; if timeout 10 grep -qm1 '\[BUDDY\] started' <(tail -n 1000 -f /tmp/searchd.log); then echo 'Buddy started!'; else echo 'Timeout or failed!'; cat /tmp/searchd.log;fi
––– output –––
Manticore %{SEMVER} %{COMMITDATE}#!/(\sdev)?\s/!#(columnar %{SEMVER} %{COMMITDATE}) (secondary %{SEMVER} %{COMMITDATE}) (knn %{SEMVER} %{COMMITDATE})
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-%{YEAR}, Manticore Software LTD (https://manticoresearch.com)
[#!/[0-9]{2}:[0-9]{2}.[0-9]{3}/!#] [#!/[0-9]+/!#] using config file '/tmp/116.conf' (%{NUMBER} chars)...
[#!/[0-9]{2}:[0-9]{2}.[0-9]{3}/!#] [#!/[0-9]+/!#] using config file '/tmp/watchdog-off.conf' (%{NUMBER} chars)...
starting daemon version '%{SEMVER} %{COMMITDATE}#!/(\sdev)?\s/!#(columnar %{SEMVER} %{COMMITDATE}) (secondary %{SEMVER} %{COMMITDATE}) (knn %{SEMVER} %{COMMITDATE})' ...
listening on all interfaces for mysql, port=9315
listening on all interfaces for mysql, port=9306
listening on all interfaces for sphinx and http(s), port=9316
Buddy started!
––– input –––
mysql -P9315 -h0 -e "drop table if exists t; create table t(s string); insert into t values(1, 'a'); flush ramchunk t"; echo $?
mysql -P9306 -h0 -e "DROP TABLE IF EXISTS t;"; rm -rf /tmp/data/t; mysql -P9306 -h0 -e "CREATE TABLE t(id INT, s STRING);"
––– output –––
0
––– input –––
mysql -P9315 -h0 -e "select * from t;"
for n in `seq 1 100000`; do echo "INSERT INTO t VALUES($n, 'a');" >> /tmp/insert.sql; done; mysql -P9306 -h0 < /tmp/insert.sql; mysql -P9306 -h0 -e "FLUSH RAMCHUNK t;"
––– output –––
+------+------+
| id | s |
+------+------+
| 1 | a |
+------+------+
––– input –––
rm -f /tmp/update.sql; for n in `seq 1 10000`; do echo "update t set s='b' where id=1;" >> /tmp/update.sql; done; while true; do mysql -P9315 -h0 < /tmp/update.sql | break; done &
mysql -P9306 -h0 -e "SELECT COUNT(*) FROM t;"
––– output –––
[#!/[0-9]{1}/!#] %{NUMBER}
+----------+
| count(*) |
+----------+
| 100000 |
+----------+
––– input –––
sleep 30; mysql -P9315 -h0 -e "select * from t;"
rm -f /tmp/update.sql; for n in `seq 1 100`; do echo "UPDATE t SET s='b' WHERE id=$n;" >> /tmp/update.sql; done; while true; do mysql -P9306 -h0 < /tmp/update.sql; done & UPDATE_PID=$!
––– output –––
+------+------+
| id | s |
+------+------+
| 1 | b |
+------+------+
[%{NUMBER}] %{NUMBER}
––– input –––
stdbuf -oL mysql -P9315 -h0 -e "freeze t"
sleep 1; mysql -P9306 -h0 -e "freeze t"
––– output –––
+------------------------+------------------------+
| file | normalized |
Expand All @@ -59,19 +53,35 @@ stdbuf -oL mysql -P9315 -h0 -e "freeze t"
| /tmp/data/t/t.settings | /tmp/data/t/t.settings |
+------------------------+------------------------+
––– input –––
mysql -P9315 -h0 -e "unfreeze t"; echo $?
sleep 1; kill $UPDATE_PID; wait $UPDATE_PID 2>/dev/null; mysql -P9306 -h0 -e "unfreeze t"; echo $?
––– output –––
0
––– input –––
mysql -P9315 -h0 -e "DESCRIBE t"
(sleep 1; mysql -P9306 -h0 -e "drop table if exists t;" && mysql -P9306 -h0 -e "CREATE TABLE t(a string); insert into t values(1, 'a'); flush ramchunk t; freeze t"; mysql -P9306 -h0 -e "update t set a='b' where id = 1" 2>&1 &)
––– output –––
+-------+--------+------------+
| Field | Type | Properties |
+-------+--------+------------+
| id | bigint | |
| s | string | |
+-------+--------+------------+
+------------------------+------------------------+
| file | normalized |
+------------------------+------------------------+
| /tmp/data/t/t.0.spa | /tmp/data/t/t.0.spa |
| /tmp/data/t/t.0.spb | /tmp/data/t/t.0.spb |
| /tmp/data/t/t.0.spd | /tmp/data/t/t.0.spd |
| /tmp/data/t/t.0.spe | /tmp/data/t/t.0.spe |
| /tmp/data/t/t.0.sph | /tmp/data/t/t.0.sph |
| /tmp/data/t/t.0.sphi | /tmp/data/t/t.0.sphi |
| /tmp/data/t/t.0.spi | /tmp/data/t/t.0.spi |
| /tmp/data/t/t.0.spidx | /tmp/data/t/t.0.spidx |
| /tmp/data/t/t.0.spm | /tmp/data/t/t.0.spm |
| /tmp/data/t/t.0.spp | /tmp/data/t/t.0.spp |
| /tmp/data/t/t.0.spt | /tmp/data/t/t.0.spt |
| /tmp/data/t/t.meta | /tmp/data/t/t.meta |
| /tmp/data/t/t.settings | /tmp/data/t/t.settings |
+------------------------+------------------------+
––– input –––
mysql -P9315 -h0 -e "UPDATE t SET s='с' WHERE id=1; FLUSH RAMCHUNK t"; echo $?
if timeout 5 mysql -P9306 -h0 -e 'SELECT * FROM t'; then echo 'Query executed'; else echo 'Query not executed'; fi
––– output –––
0
+------+------+
| id | a |
+------+------+
| 1 | a |
+------+------+
Query executed