Add pidfile support for TiDB#64
Conversation
datacharmer
left a comment
There was a problem hiding this comment.
The goal is to have the a consistent output from the sandbox scripts, as some of the text returned by script execution is evaluated in the functional tests.
- status should return "on" and "off"
- start should check for the server health and write the result accordingly. Currently, it exits with zero regardless. Could we perhaps check for the socket existence in a loop, since the PID is being generated in the script? If we do that, we can remove the fixed sleep instruction.
- For consistency, start should not advertise "starting" but say what happened afterwards ("sandbox server started" or "sandbox server not started yet".
BTW, why do master downloads return different versions for MacOS and Linux? (#62 (comment)) I get 2.1.0 on MacOS and 3.0.0 on Linux.
I suspect that MacOS builds might not be regenerating daily. Master should not be returning 3.0.0. I will ask the build team to look into it, but in my mind, we should only be targeting 3.0+ since it has support for tcp+unix socket. It will also now advertise socket/port/datadir correctly. Thank you for the feedback, I will incorporate. |
Changed use and status to use regular template Fixed other templates to return compatible error codes and messages
Don't say starting until after attempted
|
I've updated some temporary packages to: I've verified they work on Mac OS and Linux, but they were manually created.. so no guarantees. I have incorporated the changes requested in your review. In addition, the |
|
Thanks for the update. |
|
Sure, I'll take a look. At quick glance it looks like the mock template writes a pid file (which in the case of TiDB the start script does), so conceptually it only needs to check that a Do I need to add a sleep in there so it is a "running server"? I assume I don't need to patch |
|
Correct. We should not change The mock server is generated with a procedure similar to what we do in set-mock.sh. The test that is failing is in sandbox_test.go Run as |
datacharmer
left a comment
There was a problem hiding this comment.
I can make the whole thing work (adding a new mock template for tidb-server that generates the right "almost" socket file) but only if we change the restrictive -S in start to a more relaxed -e.
Suggestions?
|
|
||
| lsof -Pi :{{.Port}} -sTCP:LISTEN -t >/dev/null | ||
| exit $?` | ||
| if [ -S {{.GlobalTmpDir}}/mysql_sandbox{{.Port}}.sock ] |
There was a problem hiding this comment.
| if [ -S {{.GlobalTmpDir}}/mysql_sandbox{{.Port}}.sock ] | |
| if [ -e {{.GlobalTmpDir}}/mysql_sandbox{{.Port}}.sock ] |
See above comment
Co-Authored-By: morgo <tocker@gmail.com>
* Implement flavor and capabilities support Implement Issue #49 Add support for --client-from=X Implement Issue #50 Change evaluation of version to include a flavor Fix Issue #51 unpack command fails when tarball name doesn't include a version Implement Issue #52 unpack command should create a FLAVOR file for the extracted tarball Add command "dbdeployer admin capabilities [flavor [version]]" Ensure tiDB binaries are recognized as valid. Look for mysql_install_db only when flavor + version need it. Fix Go native tests to use flavor and client basedir. Code formatting. Add tiDB templates code formatting and annotations update .gitignore and improve main test script Add use template, fixed bug in CONTRIBUTING fix bug in add_option filename Add fix to kill script Add check for template name uniqueness Add check for tidb template names to use a known prefix Add check to prevent replication with tidb flavor Add flavor detection based on files in expanded tarball Fix unpack panic when top directory not in tarball Add tests for TiDB, flavor detection, capabilities Fix Issue #48 MySQLx and group replication Fix Issue #48 "can't enable mysqlx and group replication at the same time" Add new script and better flavor support Change "remote get" docs to reflect changed names Fix Issue #62 TiDB fails on MacOS Add script "after_start" to sandboxes (does nothing by default, but it is used by TiDB to clean-up unwanted scripts) Add pidfile support for TiDB (#64) Chang tiDB use and status to use regular template Fix other templates to return compatible error codes and messages Improve Travis test execution flow Fix mock tests for TiDB Add functional tests for TiDB
I checked out how this is implemented in MySQL, and it is not a feature of
mysqld, but rathermysqld_safe. TiDB does not have a comparable tomysqld_safe, and since many modern oses use something like systemd for this instead, it does not make sense to implement one (it has been a source of many security vulnerabilities too).So instead I modified the start script to generate a pid file, and modified the stop and status scripts to use it. It seems to work fine (only tested on Linux, but I tried not to use any specific features).
The stop and status scripts check for the pid file, in addition to the start script checking for stale pid files.