Skip to content

Instantly share code, notes, and snippets.

@BohuTANG
Last active September 18, 2020 03:09
Show Gist options
  • Save BohuTANG/55cac003a358eb70adce5923be0ee60d to your computer and use it in GitHub Desktop.
Save BohuTANG/55cac003a358eb70adce5923be0ee60d to your computer and use it in GitHub Desktop.
mysql-eof.txt
1. docker mysql
sudo docker run -d -e MYSQL_ROOT_PASSWORD=123 mysql:5.7 mysqld --datadir=/var/lib/mysql --server-id=1 --log-bin=/var/lib/mysql/mysql-bin.log --gtid-mode=ON --enforce-gtid-consistency --disable-ssl --ssl=0
2. bench progoram
$ mkdir bench
$ mkdir bench/src
$ vim bench/src/run.go
```
package main
import (
"log"
"time"
"context"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db, err := sql.Open("mysql", "root:123@tcp(172.17.0.3:3306)/")
if err != nil {
panic(err.Error())
}
defer db.Close()
insert, err := db.Query("create database if not exists sbtest")
if err != nil {
panic(err.Error())
}
insert, err = db.Query("CREATE TABLE if not exists sbtest.`timestamp` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `timestamp` int(11) DEFAULT NULL, `content` varchar(9000) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB")
if err != nil {
panic(err.Error())
}
insert.Close()
for k:=0; k < 100000; k++{
ctx := context.Background()
tx, err := db.BeginTx(ctx, nil)
if err != nil {
log.Fatal(err)
}
for i := 0; i < 10; i++ {
_, err = tx.ExecContext(ctx, "insert into sbtest.timestamp (timestamp, content) values (111222333, 'The default location for binary log files is the data directory. You can use the --log-bin option to specify an alternative location, by adding a leading absolute path name to the base name to specify a different directory. When the server reads an entry from the binary log index file, which tracks the binary log files that have been used, it checks whether the entry contains a relative path. If it does, the relative part of the path is replaced with the absolute path set using the --log-bin option. An absolute path recorded in the binary log index file remains unchanged; in such a case, the index file must be edited manually to enable a new path or paths to be used. The binary log file base name and any specified path are available as the log_bin_basename system variable. In earlier MySQL versions, binary logging was disabled by default')")
if err != nil {
log.Fatal(err)
}
}
err = tx.Commit()
if err != nil {
log.Fatal(err)
}
time.Sleep(10 * time.Millisecond)
log.Print("----\n")
}
}
```
$ export GOPATH=`pwd`
$ go get ./...
$ go run src/run.go
3. clickhouse replication client
$cmake --build /home/bohu/work/ClickHouse/build --target mysql_protocol -j 4
$./build/src/Core/tests/mysql_protocol --host=172.17.0.3 --user=root --password=123 --db=sbtest
4. tcpdump if need
$sudo tcpdump -i docker0 -X -s 0 -w /tmp/eof8.cap
@BohuTANG
Copy link
Author

SELECT
id,
rowNumberInAllBlocks() + 1 AS rownumber
FROM
(
SELECT id
FROM sbtest.timestamp
ORDER BY id ASC
)
WHERE id != rownumber
LIMIT 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment