diff --git a/.gitignore b/.gitignore index 1863cd9f7f29ac761ba13653c76cbca13f6f2ec7..73ecfae0ea21755ff4b03d2245509bd12bfcc4d5 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ RPM tags extra/txt2c extra/bin2c +extra/dist/tarantoolctl.1 cmake_install.cmake config.mk doc/www/content/docs/dev_guide.html diff --git a/CMakeLists.txt b/CMakeLists.txt index f6281b7ad41999e58516a66f3d8f59bdb4b32fe5..795858239b329c656961b36d32a1b9e82a028922 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,6 @@ find_program(LYNX lynx) find_program(CAT cat) find_program(GIT git) find_program(LD ld) -find_program(POD2MAN pod2man) # Define PACKAGE macro in tarantool/config.h set (PACKAGE "Tarantool") @@ -44,6 +43,7 @@ endif() include(GNUInstallDirs) include(cmake/utils.cmake) +include(cmake/pod2man.cmake) # the order is significant: we need to know os and compiler to configure libs include(cmake/arch.cmake) diff --git a/cmake/pod2man.cmake b/cmake/pod2man.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e614dbef39be00a652c82822a7db08627873eec8 --- /dev/null +++ b/cmake/pod2man.cmake @@ -0,0 +1,34 @@ +# Generate man pages of the project by using the POD header +# written in the tool source code. To use it - include this +# file in CMakeLists.txt and invoke +# pod2man(<podfile> <manfile> <section> <center>) +find_program(POD2MAN pod2man) + +if(NOT POD2MAN) + message(STATUS "Could not find pod2man - man pages disabled") +endif(NOT POD2MAN) + +macro(pod2man PODFILE MANFILE SECTION OUTPATH CENTER) + if(NOT EXISTS ${PODFILE}) + message(FATAL ERROR "Could not find pod file ${PODFILE} to generate man page") + endif(NOT EXISTS ${PODFILE}) + + if(POD2MAN) + set(OUTPATH_NEW "${PROJECT_BINARY_DIR}/${OUTPATH}") + + add_custom_command( + OUTPUT ${OUTPATH_NEW}/${MANFILE}.${SECTION} + COMMAND ${POD2MAN} --section ${SECTION} --center ${CENTER} + --release --name ${MANFILE} ${PODFILE} + ${OUTPATH_NEW}/${MANFILE}.${SECTION} + ) + set(MANPAGE_TARGET "man-${MANFILE}") + add_custom_target(${MANPAGE_TARGET} ALL + DEPENDS ${OUTPATH_NEW}/${MANFILE}.${SECTION} + ) + install( + FILES ${OUTPATH_NEW}/${MANFILE}.${SECTION} + DESTINATION ${CMAKE_INSTALL_MANDIR}/man${SECTION} + ) + endif() +endmacro(pod2man PODFILE MANFILE SECTION OUTPATH CENTER) diff --git a/debian/changelog b/debian/changelog index 1acbd0337b96aad15b6c4c0eb4dd196916a04a0d..f17f7602096e5bc1056d52e00987e2cc26d76792 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,19 @@ -tarantool (1.6.3.183.gd309992-1) UNRELEASED; urgency=medium +tarantool (1.6.3.539.g211672f-1) unstable; urgency=medium * Init infrastructure for tarantool 1.6. - - -- Dmitry E. Oboukhov <unera@debian.org> Wed, 20 Aug 2014 17:19:14 +0400 + * Update debian/copyright: + + cmake/luatest.cpp + + third_party/PMurHash.* + + third_party/lua-yaml/* + + third_party/sha1.* + + third_party/open_memstream.* + * Add lintian-oferrides: libyaml: + tarantool has patched version of the library. + * Rename -plugin* package to -module* + * Conflicts: tarantool 1.5 (it was renamed to tarantool-lts). + * NOSTRIP /usr/bin/tarantool binary: it uses symbols runtime. + + -- Dmitry E. Oboukhov <unera@debian.org> Mon, 27 Oct 2014 14:33:07 +0300 tarantool (1.5.3.53.ge2308d8-1) unstable; urgency=medium diff --git a/debian/control b/debian/control index c54bb43cb8fb2355f1167b3300ef5544458bd119..63fb5c206153053422c11125eb9bbe3a84024648 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Build-Depends: cdbs, debhelper (>= 8), libmysqlclient-dev, libpq-dev Section: database -Standards-Version: 3.9.5 +Standards-Version: 3.9.6 Homepage: http://tarantool.org/ VCS-Browser: https://github.com/tarantool/tarantool VCS-Git: git://github.com/tarantool/tarantool.git @@ -17,7 +17,23 @@ VCS-Git: git://github.com/tarantool/tarantool.git Package: tarantool-common Architecture: all Priority: optional -Depends: ${misc:Depends}, adduser +Conflicts: tarantool-common (<< 1.5.3), + tarantool-lts-common, + tarantool-lts, + tarantool-lts-modules, + tarantool-lts-postgresql-module, + tarantool-lts-mysql-module, + tarantool-lts-dev, + tarantool-dbg (<< 1.5.2), + tarantool-common (<< 1.6~), + tarantool-client (<< 1.6~), + tarantool-client-dbg (<< 1.6~), + tarantool-plugins (<< 1.6~), + tarantool-mysql-plugin (<< 1.6~), + tarantool-postgresql-plugin (<< 1.6~), + libtarantool-dev (<< 1.6~) +Replaces: tarantool-common (<< 1.5.3), tarantool-lts-common +Depends: ${misc:Depends}, adduser, lsb-base Description: Tarantool in-memory database - common files Tarantool is an in-memory database and Lua application server. This package provides scripts to work with tarantool configuration @@ -27,7 +43,14 @@ Package: tarantool Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 hurd-i386 Priority: optional Depends: ${shlibs:Depends}, ${misc:Depends} -Conflicts: tarantool-dbg (<< 1.5.2), +Replaces: tarantool-lts +Conflicts: tarantool-lts-common, + tarantool-lts, + tarantool-lts-modules, + tarantool-lts-postgresql-module, + tarantool-lts-mysql-module, + tarantool-lts-dev, + tarantool-dbg (<< 1.5.2), tarantool-common (<< 1.6~), tarantool-client (<< 1.6~), tarantool-client-dbg (<< 1.6~), @@ -52,8 +75,22 @@ Description: In-memory database with Lua application server This package provides Tarantool server. Package: tarantool-modules -Conflicts: tarantool-plugins (<< 1.5.3) -Replaces: tarantool-plugins (<< 1.5.3) +Conflicts: tarantool-plugins (<< 1.5.3), + tarantool-lts-common, + tarantool-lts, + tarantool-lts-modules, + tarantool-lts-postgresql-module, + tarantool-lts-mysql-module, + tarantool-lts-dev, + tarantool-dbg (<< 1.5.2), + tarantool-common (<< 1.6~), + tarantool-client (<< 1.6~), + tarantool-client-dbg (<< 1.6~), + tarantool-plugins (<< 1.6~), + tarantool-mysql-plugin (<< 1.6~), + tarantool-postgresql-plugin (<< 1.6~), + libtarantool-dev (<< 1.6~) +Replaces: tarantool-plugins (<< 1.5.3), tarantool-lts-modules Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 hurd-i386 Priority: optional Depends: @@ -69,8 +106,22 @@ Description: Tarantool in-memory database - all plug-ins bundle modules. Package: tarantool-postgresql-module -Conflicts: tarantool-postgresql-plugin (<< 1.5.3) -Replaces: tarantool-postgresql-plugin +Conflicts: tarantool-postgresql-plugin (<< 1.5.3), + tarantool-lts-common, + tarantool-lts, + tarantool-lts-modules, + tarantool-lts-postgresql-module, + tarantool-lts-mysql-module, + tarantool-lts-dev, + tarantool-dbg (<< 1.5.2), + tarantool-common (<< 1.6~), + tarantool-client (<< 1.6~), + tarantool-client-dbg (<< 1.6~), + tarantool-plugins (<< 1.6~), + tarantool-mysql-plugin (<< 1.6~), + tarantool-postgresql-plugin (<< 1.6~), + libtarantool-dev (<< 1.6~) +Replaces: tarantool-postgresql-plugin, tarantool-lts-postgresql-module Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 hurd-i386 Priority: optional Depends: ${shlibs:Depends}, ${misc:Depends}, @@ -82,8 +133,22 @@ Description: Tarantool in-memory database - PostgreSQL connector Tarantool Lua stored procedures. Package: tarantool-mysql-module -Conflicts: tarantool-mysql-plugin (<< 1.5.3) -Replaces: tarantool-mysql-plugin +Conflicts: tarantool-mysql-plugin (<< 1.5.3), + tarantool-lts-common, + tarantool-lts, + tarantool-lts-modules, + tarantool-lts-postgresql-module, + tarantool-lts-mysql-module, + tarantool-lts-dev, + tarantool-dbg (<< 1.5.2), + tarantool-common (<< 1.6~), + tarantool-client (<< 1.6~), + tarantool-client-dbg (<< 1.6~), + tarantool-plugins (<< 1.6~), + tarantool-mysql-plugin (<< 1.6~), + tarantool-postgresql-plugin (<< 1.6~), + libtarantool-dev (<< 1.6~) +Replaces: tarantool-mysql-plugin, tarantool-lts-mysql-module Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 hurd-i386 Priority: optional Depends: ${shlibs:Depends}, ${misc:Depends}, @@ -98,6 +163,21 @@ Package: tarantool-dev Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 hurd-i386 Priority: optional Section: libdevel +Replaces: tarantool-lts-dev +Conflicts: tarantool-lts-common, + tarantool-lts, + tarantool-lts-modules, + tarantool-lts-postgresql-module, + tarantool-lts-mysql-module, + tarantool-lts-dev, + tarantool-dbg (<< 1.5.2), + tarantool-common (<< 1.6~), + tarantool-client (<< 1.6~), + tarantool-client-dbg (<< 1.6~), + tarantool-plugins (<< 1.6~), + tarantool-mysql-plugin (<< 1.6~), + tarantool-postgresql-plugin (<< 1.6~), + libtarantool-dev (<< 1.6~) Depends: ${shlibs:Depends}, ${misc:Depends}, tarantool (= ${binary:Version}) Description: Tarantool in-memory database - development headers diff --git a/debian/copyright b/debian/copyright index 67069282cecd7d75547bc77b87ef772c93651d7b..6d01443b320c667ca7740889dba61f5843a2ba0b 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,4 +1,4 @@ -Format: http://dep.debian.net/deps/dep5/ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Debianized-By: Dmitry E. Oboukhov <unera@debian.org> Upstream-Name: tarantool, tarantool-box Upstream-Contact: tarantool-developers@lists.launchpad.net @@ -6,7 +6,7 @@ Source: https://github.com/tarantool/tarantool Files: third_party/libev/* third_party/coro/* third_party/libeio/* Copyright: 2007-2012 Marc Alexander Lehmann. -License: +License: BSD-2-Clause or GPL Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -48,7 +48,7 @@ License: Files: third_party/libev/event_compat.h Copyright: 2000-2004 Niels Provos <provos@citi.umich.edu>, 2008 Marc Alexander Lehmann <libev@schmorp.de> -License: +License: BSD-3-Clause All rights reserved. . Redistribution and use in source and binary forms, with or without @@ -76,7 +76,7 @@ License: Files: third_party/libev/ev.c Copyright: 2007-2012 Marc Alexander Lehmann <libeio@schmorp.de>, 2011 Emanuele Giaquinta -License: +License: BSD-2-Clause Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: . @@ -97,10 +97,10 @@ License: WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Files: third_party/coro/conftest.c Copyright: 1999-2001 Ralf S. Engelschall <rse@engelschall.com> -License: +License: LGPL-2.1 This file is part of GNU Pth, a non-preemptive thread scheduling library which can be found at http://www.gnu.org/software/pth/. . @@ -125,7 +125,7 @@ License: Files: third_party/crc32.c Copyright: 1986 Gary S. Brown. 2004-2006 Intel Corporation - All Rights Reserved -License: +License: BSD-3-Clause You may use this program, or code or tables extracted from it, as desired without restriction. . @@ -156,7 +156,7 @@ License: Files: third_party/memrchr.c third_party/memmem.c Copyright: 2008 The NetBSD Foundation, Inc. -License: +License: BSD-2-Clause All rights reserved. . This code is derived from software contributed to The NetBSD Foundation @@ -185,7 +185,7 @@ License: Files: third_party/memcached/* Copyright: 2003, Danga Interactive, Inc. -License: +License: BSD-3-Clause Copyright (c) 2003, Danga Interactive, Inc. All rights reserved. . @@ -217,10 +217,10 @@ License: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Files: third_party/luajit/* +Files: third_party/luajit/* cmake/luatest.cpp Copyright: 2005-2011 Mike Pall. All rights reserved. 1994-2011 Lua.org, PUC-Rio. -License: +License: MIT LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ . Copyright (C) 2005-2011 Mike Pall. All rights reserved. @@ -276,7 +276,7 @@ License: Files: test/lib/yapps/* Copyright: 1999-2003 Amit J. Patel <amitp@cs.stanford.edu> 2003-2004 by Matthias Urlichs <smurf@debian.org> -License: +License: MIT The MIT License (MIT) . Permission is hereby granted, free of charge, to any person obtaining a copy @@ -298,10 +298,13 @@ License: THE SOFTWARE. Files: third_party/qsort_arg.c + third_party/qsort_arg_mt.c + third_party/compat/sys/bsd_time.h third_party/queue.h connector/c/tntsql/include/tnt_queue.h + third_party/rb.h Copyright: 1992, 1993 The Regents of the University of California. -License: +License: BSD-3-Clause All rights reserved. . Redistribution and use in source and binary forms, with or without @@ -329,9 +332,53 @@ License: OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Files: third_party/compat/unwind.h +Copyright: 2001, 2003, 2004, 2006 Free Software Foundation, Inc. +License: GPL + This file is part of GCC. + . + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + . + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + . + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + . + As a special exception, if you include this header file into source + files compiled by GCC, this header file does not by itself cause + the resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU General + Public License. + +Files: third_party/gopt/gopt.* +Copyright: 2003-2008, Tom Vajzovic <tom.viza@gmail.com> +License: TFL + I, Tom Vajzovic, am the author of this software and its documentation + and permanently abandon all copyright and other intellectual property + rights in them, including the right to be identified as the author. + . + I am fairly certain that this software does what its documentation says + that it does, but I do not guarantee that it does, or that it does what + you think it should. I do not guarantee that it will not have undesirable + side effects. + . + You are free to use, modify and distribute this software as you please, + but you do so at your own risk. If you remove or hide this warning then + you may be responsible for any problems that are encountered by those who + obtain the software through you. + Files: third_party/valgrind/* Copyright: 2000-2010 Julian Seward. -License: +License: BSD-4-Clause All rights reserved. . Redistribution and use in source and binary forms, with or without @@ -368,7 +415,7 @@ License: Files: third_party/sptree.h Copyright: 2010 Mail.RU 2010 Teodor Sigaev -License: +License: BSD-2-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -393,7 +440,7 @@ License: Files: third_party/proctitle.c Copyright: 2000-2010 PostgreSQL Global Development Group -License: +License: BSD-2-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -418,7 +465,7 @@ License: Files: third_party/lua-cjson/* Copyright: 2010-2012 Mark Pulford <mark@kyne.com.au> -License: +License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including @@ -440,7 +487,7 @@ License: Files: third_party/lua-cjson/g_fmt.c Copyright: 1991, 1996 by Lucent Technologies. -License: +License: Expat The author of this software is David M. Gay. . Permission to use, copy, modify, and distribute this software for any @@ -456,7 +503,7 @@ License: Files: src/rope.c Copyright: 1993-1994 by Xerox Corporation. -License: +License: BSD-2-Clause Author: Hans-J. Boehm <boehm@parc.xerox.com> . Redistribution and use in source and binary forms, with or @@ -497,7 +544,7 @@ License: Files: third_party/base64.[ch] Copyright: Chris Venter <chris.venter@gmail.com> -License: +License: BSD-2-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -525,25 +572,47 @@ License: THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Files: debian/* * -Copyright: Aleksey Demakov, - Aleksey Mashanov, - Alexandre Kalendarev, - Damien Lefortier, - Dmitry E. Oboukhov, - Dmitry Simonenko, - Fedor Sigaev, - Konstantin Osipov, - Konstantin Shulgin, - Yuri Nevinitsin, - Pavel Cherenkov, - Roman Antipin, - Roman Tokarev, - Teodor Sigaev, - Timofey Khryukin, - Yuriy Nevinitsin, - Yuriy Vostrikov -License: +Files: third_party/PMurHash.* +Copyright: Austin Appleby +License: Public-Domain + MurmurHash3 was written by Austin Appleby, and is placed in the public + domain. + . + This implementation was written by Shane Day, and is also public domain. + . + This is a portable ANSI C implementation of MurmurHash3_x86_32 (Murmur3A) + with support for progressive processing. + +Files: third_party/lua-yaml/* +Copyright: 2009, Andrew Danforth +License: Expat + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +Files: ./third_party/sha1.* +Copyright: Steve Reid <steve@edmweb.com> +License: Public-Domain + Public Domain. + +Files: third_party/open_memstream.* +Copyright: 2013 Advanced Computing Technologies LLC, + Written by: John H. Baldwin <jhb@FreeBSD.org> +License: BSD-2-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -554,10 +623,10 @@ License: notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . - THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -565,3 +634,38 @@ License: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Files: * +Copyright: 2010-2014 by Aleksey Demakov, Aleksey Mashanov, + Alexandre Kalendarev, Damien Lefortier, Dmitry E. Oboukhov, + Dmitry Simonenko, Konstantin Osipov, Konstantin Shulgin, + Mons Anderson, Pavel Cherenkov, Roman Antipin, Roman Tokarev, + Roman Tsisyk, Teodor Sigaev, Timofey Khryukin, Yuriy Nevinitsin, + Yuriy Vostrikov, Veniamin Gvozdikov +License: BSD-2-Clause + Redistribution and use in source and binary forms, with or + without modification, are permitted provided that the following + conditions are met: + . + 1. Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + . + 2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. diff --git a/debian/rules b/debian/rules index 1ba99320c456dc2632fdd825aa78fb905c23bbc5..e647e764acef0c699a5c1561240bcedc2bd3c289 100755 --- a/debian/rules +++ b/debian/rules @@ -29,9 +29,9 @@ DEB_CMAKE_NORMAL_ARGS := -DCMAKE_INSTALL_PREFIX="$(DEB_CMAKE_INSTALL_PREFIX)" \ # -DCMAKE_C_COMPILER:FILEPATH="$(CC)" \ # -DCMAKE_CXX_COMPILER:FILEPATH="$(CXX)" \ -DEB_SHLIBDEPS_INCLUDE := /usr/lib/tarantool +DEB_SHLIBDEPS_INCLUDE := /usr/lib/tarantool DEB_INSTALL_DOCS_ALL := -XTODO -XAUTHORS -DEB_DH_STRIP_ARGS_tarantool := -X/usr/bin/tarantool +DEB_DH_STRIP_ARGS := -X/usr/bin/tarantool include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/cmake.mk @@ -40,6 +40,7 @@ DEB_BUILDDIR := build-area DIRNAME=$(shell basename $(CURDIR)) + tarball: clean git describe > VERSION cd .. && tar --exclude=.git --exclude=debian \ @@ -60,9 +61,3 @@ clean:: install/tarantool:: - -install/tarantool-common:: - sed 's/dist.lua/tarantoolctl/g' extra/dist/dist.lua \ - > ${DEB_BUILDDIR}/tarantoolctl - pod2man -c 'tarantoolctl instances control' \ - ${DEB_BUILDDIR}/tarantoolctl > ${DEB_BUILDDIR}/tarantoolctl.1 diff --git a/debian/tarantool-common.manpages b/debian/tarantool-common.manpages index 58d0e39064e5094d2d4d4ef45b793c76ffea7dc9..6198544dcb4a7a1a2cfb0ffc6c788c0bbf6e0635 100644 --- a/debian/tarantool-common.manpages +++ b/debian/tarantool-common.manpages @@ -1 +1 @@ -build-area/tarantoolctl.1 +build-area/extra/dist/tarantoolctl.1 diff --git a/debian/tarantool.lintian-overrides b/debian/tarantool.lintian-overrides index 79de2b236e53ae6dff1c40a7d0a33221e1a1fd18..67d2005c096b6ec202b10db73b9def47293fbf66 100644 --- a/debian/tarantool.lintian-overrides +++ b/debian/tarantool.lintian-overrides @@ -1 +1,2 @@ tarantool: unstripped-binary-or-object usr/bin/tarantool +tarantool: embedded-library usr/bin/tarantool: libyaml diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 08cecf116b37db38cdbbce074fc9690c4015da5d..578a99d64fe880ec411cf0cc1c2d4b3b42101d57 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_target(man ALL - COMMAND ${POD2MAN} -c 'Lua application server and NoSQL database' - ${CMAKE_SOURCE_DIR}/doc/man/tarantool.pod > ${PROJECT_BINARY_DIR}/doc/man/tarantool.1 - ) -install(FILES ${PROJECT_BINARY_DIR}/doc/man/tarantool.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/) +pod2man ( + ${CMAKE_SOURCE_DIR}/doc/man/tarantool.pod + "tarantool" 1 doc/man + "Lua application server and NoSQL database" +) diff --git a/doc/user/server-administration.xml b/doc/user/server-administration.xml index e3c279dbb66b80e5421d736606ff1d3b9de9ea85..09d6cfa7b02aefab3ec65787555d57c0aa0ce204 100644 --- a/doc/user/server-administration.xml +++ b/doc/user/server-administration.xml @@ -207,15 +207,15 @@ Explanatory notes about what tarantool displayed in the above example: </section> -<section xml:id="dist.lua"> -<title>Utility <code>dist.lua</code></title> +<section xml:id="tarantoolctl"> +<title>Utility <code>tarantoolctl</code></title> <para> -With dist.lua one can say: "start an instance of the +With tarantoolctl one can say: "start an instance of the Tarantool server which runs a single user-written Lua program, allocating disk resources specifically for that program, via a standardized deployment method." If Tarantool was downloaded from source, then the script -is in ~/extra/dist/dist.lua. If Tarantool was installed +is in ~/extra/dist/tarantoolctl. If Tarantool was installed with debian or Red Hat installation packages, the script is renamed <code>tarantoolctl</code> and is in /usr/bin/tarantoolctl. The script handles such things as: @@ -223,12 +223,12 @@ starting, stopping, rotating logs, logging in to the application's console, and checking status. </para> -<bridgehead renderas="sect4">configuring for dist.lua</bridgehead> +<bridgehead renderas="sect4">configuring for tarantoolctl</bridgehead> <para> -The dist.lua script will read a configuration file +The tarantoolctl script will read a configuration file named /etc/sysconfig/tarantool, or /etc/default/tarantool. Most of the settings are similar to the settings -used by <code>box.cfg{...}</code>; however, dist.lua +used by <code>box.cfg{...}</code>; however, tarantoolctl adjusts some of them by adding an application name. A copy of /etc/sysconfig/tarantool, with defaults for all settings, would look like this:<programlisting> @@ -270,33 +270,33 @@ username = the user that runs the tarantool server. </para> <para> instance_dir = the directory where all applications for this host are stored. -The user who writes an application for dist.lua must put the application's +The user who writes an application for tarantoolctl must put the application's source code in this directory, or a symbolic link. For examples in this section the application name <code>my_app</code> will be used, and its source will have to be in <code><replaceable>instance_dir</replaceable>/my_app.lua</code>. </para> -<bridgehead renderas="sect4">commands for dist.lua</bridgehead> +<bridgehead renderas="sect4">commands for tarantoolctl</bridgehead> <para> -The command format is <code>dist.lua <replaceable>operation</replaceable> application-name</code>, +The command format is <code>tarantoolctl <replaceable>operation</replaceable> application-name</code>, where <replaceable>operation</replaceable> is one of: <code>start</code>, <code>stop</code>, <code>status</code>, <code>logrotate</code>, <code>enter</code>. Thus ...<programlisting> -dist.lua start my_app -- starts application my_app -dist.lua stop my_app -- stops my_app -dist.lua enter my_app -- show my_app's admin console, if it has one -dist.lua logrotate my_app -- rotate my_app's log files (make new, remove old) -dist.lua status my_app -- check my_app's status</programlisting> +tarantoolctl start my_app -- starts application my_app +tarantoolctl stop my_app -- stops my_app +tarantoolctl enter my_app -- show my_app's admin console, if it has one +tarantoolctl logrotate my_app -- rotate my_app's log files (make new, remove old) +tarantoolctl status my_app -- check my_app's status</programlisting> </para> -<bridgehead renderas="sect4">typical code snippets for dist.lua</bridgehead> +<bridgehead renderas="sect4">typical code snippets for tarantoolctl</bridgehead> <para> A user can check whether my_app is running with these lines:<programlisting> - if dist.lua status my_app; then + if tarantoolctl status my_app; then ... fi</programlisting> A user can initiate, for boot time, an init.d set of instructions:<programlisting> for (each file mentioned in the instance_dir directory): - dist.lua start `basename $ file .lua`</programlisting> + tarantoolctl start `basename $ file .lua`</programlisting> A user can set up a further configuration file for log rotation, like this:<programlisting> /path/to/tarantool/*.log { daily @@ -307,15 +307,15 @@ A user can set up a further configuration file for log rotation, like this:<prog delaycompress create 0640 tarantool adm postrotate - /path/to/dist.lua logrotate `basename $ 1 .log` + /path/to/tarantoolctl logrotate `basename $ 1 .log` endscript }</programlisting> </para> -<bridgehead renderas="sect4">A detailed example for dist.lua</bridgehead> +<bridgehead renderas="sect4">A detailed example for tarantoolctl</bridgehead> <para> The example's objective is: make a temporary directory -where dist.lua can start a long-running application +where tarantoolctl can start a long-running application and monitor it. </para> <para> @@ -330,17 +330,17 @@ Create a directory named /tarantool_test:<programlisting> sudo mkdir /tarantool_test</programlisting> </para> <para> -Copy dist.lua to /tarantool_test. +Copy tarantoolctl to /tarantool_test. If you made a source download to ~/tarantool-master, then<programlisting> -sudo cp ~/tarantool-master/extra/dist/dist.lua /tarantool_test/dist.lua</programlisting> +sudo cp ~/tarantool-master/extra/dist/tarantoolctl /tarantool_test/tarantoolctl</programlisting> If the file was named tarantoolctl and placed on /usr/bin/tarantoolctl, then<programlisting> -sudo cp /usr/bin/tarantoolctl /tarantool_test/dist.lua</programlisting> +sudo cp /usr/bin/tarantoolctl /tarantool_test/tarantoolctl</programlisting> </para> <para> -Check and possibly change the first line of /tarantool_test/dist.lua. +Check and possibly change the first line of /tarantool_test/tarantoolctl. Initially it says<programlisting> #!/usr/bin/env tarantool</programlisting> -If that is not correct, edit dist.lua and change the line. +If that is not correct, edit tarantoolctl and change the line. For example, if the Tarantool server is actually on /home/user/tarantool-master/src/tarantool, change the line to<programlisting> #!/usr/bin/env /home/user/tarantool-master/src/tarantool</programlisting> @@ -380,9 +380,9 @@ while 0 == 0 do end</programlisting> </para> <para> -Tell dist.lua to start the application ...<programlisting> +Tell tarantoolctl to start the application ...<programlisting> cd /tarantool_test -sudo ./dist.lua start my_app</programlisting> +sudo ./tarantoolctl start my_app</programlisting> ... expect to see messages indicating that the instance has started. Then ...<programlisting> ls -l /tarantool_test/my_app</programlisting> ... expect to see the .snap file, .xlog file, and sophia directory. Then ...<programlisting> @@ -398,8 +398,8 @@ box.space.tester:select({0},{iterator='GE'})</programlisting> ... expect to see several tuples that my_app has created. </para> <para> -Stop. The only clean way to stop my_app is with dist_lua, thus:<programlisting> -sudo ./dist.lua stop my_app</programlisting> +Stop. The only clean way to stop my_app is with tarantoolctl, thus:<programlisting> +sudo ./tarantoolctl stop my_app</programlisting> </para> <para> Clean up. Restore the original contents of /etc/sysconfig/tarantool, and ...<programlisting> diff --git a/extra/dist/CMakeLists.txt b/extra/dist/CMakeLists.txt index 421689d801a0611a241cf556edaff8778537ff53..0e4f968d04703f15db0f62b8e427a094e437f3d2 100644 --- a/extra/dist/CMakeLists.txt +++ b/extra/dist/CMakeLists.txt @@ -1,4 +1,4 @@ -# Scripts for a dist.lua packaging +# Scripts for a tarantoolctl packaging set(SYSV_INITD_PATH ${CMAKE_INSTALL_LIBDIR}/tarantool/tarantool.init) configure_file("tarantool.service.in" "tarantool.service") @@ -40,10 +40,16 @@ else (ENABLE_RPM) WORLD_READ) endif(ENABLE_RPM) -install (FILES dist.lua DESTINATION ${CMAKE_INSTALL_BINDIR} -RENAME tarantoolctl -PERMISSIONS -OWNER_READ OWNER_WRITE -GROUP_READ GROUP_EXECUTE -WORLD_READ WORLD_EXECUTE) +install (FILES tarantoolctl DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS + OWNER_READ OWNER_WRITE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE +) + +pod2man ( + ${CMAKE_SOURCE_DIR}/extra/dist/tarantoolctl + "tarantoolctl" 1 extra/dist + "tarantoolctl instances control" +) diff --git a/extra/dist/tarantool.init b/extra/dist/tarantool.init index e51da35e49752baa400357fd3a28c36001c6f02d..dbf1c3428869683eaeb9239255a5508c1e6b17aa 100644 --- a/extra/dist/tarantool.init +++ b/extra/dist/tarantool.init @@ -18,6 +18,8 @@ SCRIPTNAME=/etc/init.d/tarantool DAEMON=/usr/bin/tarantool DIST_LUA=/usr/bin/tarantoolctl +. /lib/lsb/init-functions + # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 diff --git a/extra/dist/tarantool.service.in b/extra/dist/tarantool.service.in index cbcde05810b27e854ff4c5d3422b966415544c8b..b930d6ea9d5c1c096c02a37feb04a2455d3d1a28 100644 --- a/extra/dist/tarantool.service.in +++ b/extra/dist/tarantool.service.in @@ -4,7 +4,7 @@ # Recommended way: # 1) Use "/etc/sysconfig/tarantool" or "/etc/default/tarantool" - -# They're supported by our start-stop utility - dist.lua +# They're supported by our start-stop utility - tarantoolctl # Usual way for RPM-based distros # 2) Create a file "/etc/systemd/system/tarantool.service", diff --git a/extra/dist/dist.lua b/extra/dist/tarantoolctl similarity index 90% rename from extra/dist/dist.lua rename to extra/dist/tarantoolctl index 8d1f0ddd7e039c79eb444d2215c03d7e52a61940..d9f5b156006473d5616c953eae7facbfabce8e68 100755 --- a/extra/dist/dist.lua +++ b/extra/dist/tarantoolctl @@ -4,14 +4,14 @@ =head1 NAME -dist.lua - an utility to control tarantool instances +tarantoolctl - an utility to control tarantool instances =head1 SYNOPSIS vim /etc/tarantool/instances.enabled/my_instance.lua - dist.lua start my_instance - dist.lua stop my_instance - dist.lua logrotate my_instance + tarantoolctl start my_instance + tarantoolctl stop my_instance + tarantoolctl logrotate my_instance =head1 DESCRIPTION @@ -25,16 +25,16 @@ The file contains common default instances options: default_cfg = { -- will become pid_file .. instance .. '.pid' pid_file = "/var/run/tarantool", - + -- will become wal_dir/instance/ wal_dir = "/var/lib/tarantool", - + -- snap_dir/instance/ snap_dir = "/var/lib/tarantool", -- sophia_dir/instance/ sophia_dir = "/var/lib/tarantool/sophia", - + -- logger/instance .. '.log' logger = "/var/log/tarantool", @@ -47,27 +47,27 @@ The file contains common default instances options: The file defines C<instance_dir> where user can place his applications (instances). -Each instance can be controlled by C<dist.lua>: +Each instance can be controlled by C<tarantoolctl>: =head2 Starting instance - dist.lua start instance_name + tarantoolctl start instance_name =head2 Stopping instance - dist.lua stop instance_name + tarantoolctl stop instance_name =head2 Logrotate instance's log - dist.lua logrotate instance_name + tarantoolctl logrotate instance_name =head2 Enter instance admin console - dist.lua enter instance_name + tarantoolctl enter instance_name =head2 status - dist.lua status instance_name + tarantoolctl status instance_name Check if instance is up. @@ -81,8 +81,8 @@ exists and socket doesn't, etc. =head2 separate instances control If You use SysV init, You can use symlink from -C<dist.lua> to C</etc/init.d/instance_name[.lua]>. -C<dist.lua> detects if it is started by symlink and uses +C<tarantoolctl> to C</etc/init.d/instance_name[.lua]>. +C<tarantoolctl> detects if it is started by symlink and uses instance_name as C<`basename $0 .lua`>. =head1 COPYRIGHT @@ -117,7 +117,7 @@ local available_commands = { } local function usage() - log.error("Usage: %s [-w] {%s} instance_name", + log.error("Usage: %s {%s} instance_name", arg[0], table.concat(available_commands, '|')) os.exit(1) end @@ -134,16 +134,6 @@ end local cmd = arg[1] --- whether or not this is run from a wrapper which takes --- will daemonize for us -local wrapper = false - -if cmd == '-w' or cmd == '--wrapper' then - wrapper = true - shift_argv(arg, 1, 1) - cmd = arg[1] -end - local valid_cmd = false for _, vcmd in pairs(available_commands) do if cmd == vcmd then @@ -225,11 +215,11 @@ function mk_default_dirs(cfg) if fio.stat(pid_dir) == nil then mkdir(pid_dir) end - -- create wal_dir + -- create wal_dir if fio.stat(cfg.wal_dir) == nil then mkdir(cfg.wal_dir) end - -- create snap_dir + -- create snap_dir if fio.stat(cfg.snap_dir) == nil then mkdir(cfg.snap_dir) end @@ -247,7 +237,7 @@ end local force_cfg = { pid_file = default_cfg.pid_file, username = default_cfg.username, - background = wrapper ~= true, + background = true, custom_proc_title = instance } @@ -258,7 +248,7 @@ wrapper_cfg = function(cfg) cfg[i] = v end - for i, v in pairs(default_cfg) do + for i, v in pairs(default_cfg) do if cfg[i] == nil then cfg[i] = v end @@ -351,9 +341,9 @@ elseif cmd == 'enter' then log.error("Can't connect to %s (socket not found)", console_sock) os.exit(-1) end - + log.info('Connecting to %s', console_sock) - + local cmd = string.format( "require('console').connect('%s')", console_sock) @@ -395,3 +385,5 @@ else log.error("Unknown command '%s'", cmd) os.exit(-1) end + +-- vim: syntax=lua diff --git a/extra/empty.snap b/extra/empty.snap index 090233cf41eba4ac388176c20370673e5da3ae5d..3997fc8528c0be601a60bd590ddcbe847567cff8 100644 Binary files a/extra/empty.snap and b/extra/empty.snap differ diff --git a/extra/rpm/mock/tarantool-el-5-i386.cfg b/extra/rpm/mock/tarantool-el-5-i386.cfg index 9d2555fee4b4c66c43aaf7e45b6be297026738cb..13174e0ed3fbecb8d9cd57085f7589acea9c4d00 100644 --- a/extra/rpm/mock/tarantool-el-5-i386.cfg +++ b/extra/rpm/mock/tarantool-el-5-i386.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-el-5-i386' config_opts['target_arch'] = 'i386' config_opts['legal_host_arches'] = ('i386', 'i586', 'i686', 'x86_64') -config_opts['chroot_setup_cmd'] = 'install buildsys-build' +config_opts['chroot_setup_cmd'] = 'install buildsys-build scl-utils-build' config_opts['dist'] = 'el5' # only useful for --resultdir variable subst config_opts['plugin_conf']['ccache_enable'] = False # beware RHEL use 5Server or 5Client diff --git a/extra/rpm/mock/tarantool-el-5-x86_64.cfg b/extra/rpm/mock/tarantool-el-5-x86_64.cfg index 1d9ed6820f1eb514fbde5d4886155f92c6556ed6..00a777109a068b53cc217c991b6e3cdaeef9d631 100644 --- a/extra/rpm/mock/tarantool-el-5-x86_64.cfg +++ b/extra/rpm/mock/tarantool-el-5-x86_64.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-el-5-x86_64' config_opts['target_arch'] = 'x86_64' config_opts['legal_host_arches'] = ('x86_64',) -config_opts['chroot_setup_cmd'] = 'install buildsys-build' +config_opts['chroot_setup_cmd'] = 'install buildsys-build scl-utils-build' config_opts['dist'] = 'el5' # only useful for --resultdir variable subst config_opts['plugin_conf']['ccache_enable'] = False # beware RHEL use 5Server or 5Client diff --git a/extra/rpm/mock/tarantool-el-6-i386.cfg b/extra/rpm/mock/tarantool-el-6-i386.cfg index 6c0d14a6e2998a8f29053671537512e3e050285a..27e3ce9de6436223adbce7f551656836d96a8160 100644 --- a/extra/rpm/mock/tarantool-el-6-i386.cfg +++ b/extra/rpm/mock/tarantool-el-6-i386.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-el-6-i386' config_opts['target_arch'] = 'i386' config_opts['legal_host_arches'] = ('i386', 'i586', 'i686', 'x86_64') -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'el6' # only useful for --resultdir variable subst config_opts['plugin_conf']['ccache_enable'] = False # beware RHEL use 6Server or 6Client diff --git a/extra/rpm/mock/tarantool-el-6-x86_64.cfg b/extra/rpm/mock/tarantool-el-6-x86_64.cfg index e96a1356b6fffdcc14f37f656fdacbbd28bad4d0..089db14b5530254a48e6f1c7b294d1c206d344a4 100644 --- a/extra/rpm/mock/tarantool-el-6-x86_64.cfg +++ b/extra/rpm/mock/tarantool-el-6-x86_64.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-el-6-x86_64' config_opts['target_arch'] = 'x86_64' config_opts['legal_host_arches'] = ('x86_64',) -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'el6' # only useful for --resultdir variable subst config_opts['plugin_conf']['ccache_enable'] = False # beware RHEL use 6Server or 6Client diff --git a/extra/rpm/mock/tarantool-el-7-x86_64.cfg b/extra/rpm/mock/tarantool-el-7-x86_64.cfg index f03f90956027f073d98c99ae00d953008699b51b..11a154f8fd69415b09d96948ef62b47914016d1c 100644 --- a/extra/rpm/mock/tarantool-el-7-x86_64.cfg +++ b/extra/rpm/mock/tarantool-el-7-x86_64.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-el-7-x86_64' config_opts['target_arch'] = 'x86_64' config_opts['legal_host_arches'] = ('x86_64',) -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'el7' # only useful for --resultdir variable subst config_opts['yum.conf'] = """ @@ -20,7 +20,7 @@ syslog_device= # repos [el] name=el -baseurl=http://kojipkgs.fedoraproject.org/rhel/beta/7/x86_64/os/ +baseurl=http://mirror.centos.org/centos-7/7/os/x86_64/ failovermethod=priority [epel] diff --git a/extra/rpm/mock/tarantool-fedora-19-i386.cfg b/extra/rpm/mock/tarantool-fedora-19-i386.cfg index 688b1a766f9bc1eb3edb5ff0d8b47c9aab5f2923..557c10bafaf3fca9790fe4ac4794b956d254a41b 100644 --- a/extra/rpm/mock/tarantool-fedora-19-i386.cfg +++ b/extra/rpm/mock/tarantool-fedora-19-i386.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-fedora-19-i386' config_opts['target_arch'] = 'i386' config_opts['legal_host_arches'] = ('i386', 'i586', 'i686', 'x86_64') -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'fc19' # only useful for --resultdir variable subst config_opts['extra_chroot_dirs'] = [ '/run/lock', ] config_opts['releasever'] = '19' diff --git a/extra/rpm/mock/tarantool-fedora-19-x86_64.cfg b/extra/rpm/mock/tarantool-fedora-19-x86_64.cfg index 10b1913780ee0c5001017d32074f6dedc4d26c43..a1447b063f55804bc62266e0c14fbad5cb8c7950 100644 --- a/extra/rpm/mock/tarantool-fedora-19-x86_64.cfg +++ b/extra/rpm/mock/tarantool-fedora-19-x86_64.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-fedora-19-x86_64' config_opts['target_arch'] = 'x86_64' config_opts['legal_host_arches'] = ('x86_64',) -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'fc19' # only useful for --resultdir variable subst config_opts['extra_chroot_dirs'] = [ '/run/lock', ] config_opts['releasever'] = '19' diff --git a/extra/rpm/mock/tarantool-fedora-20-i386.cfg b/extra/rpm/mock/tarantool-fedora-20-i386.cfg index 3231044d3b76b4b01c6041a3ac07616fa402667e..f8bb4783f2e84c5d3b1edb691fc5db1e82514b2a 100644 --- a/extra/rpm/mock/tarantool-fedora-20-i386.cfg +++ b/extra/rpm/mock/tarantool-fedora-20-i386.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-fedora-20-i386' config_opts['target_arch'] = 'i386' config_opts['legal_host_arches'] = ('i386', 'i586', 'i686', 'x86_64') -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'fc20' # only useful for --resultdir variable subst config_opts['extra_chroot_dirs'] = [ '/run/lock', ] config_opts['releasever'] = '20' diff --git a/extra/rpm/mock/tarantool-fedora-20-x86_64.cfg b/extra/rpm/mock/tarantool-fedora-20-x86_64.cfg index 89fce7f6bb69d45e2bf265752f6e8cff604110f5..a2ab8a849e90530031ab84c2d41c687a69a8b206 100644 --- a/extra/rpm/mock/tarantool-fedora-20-x86_64.cfg +++ b/extra/rpm/mock/tarantool-fedora-20-x86_64.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-fedora-20-x86_64' config_opts['target_arch'] = 'x86_64' config_opts['legal_host_arches'] = ('x86_64',) -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'fc20' # only useful for --resultdir variable subst config_opts['extra_chroot_dirs'] = [ '/run/lock', ] config_opts['releasever'] = '20' diff --git a/extra/rpm/mock/tarantool-fedora-rawhide-i386.cfg b/extra/rpm/mock/tarantool-fedora-rawhide-i386.cfg index 86bf7479da35c3e78cce9d1cfbb4c06b57147189..46db6f37b016e9c589da646ceca2c4eb22498b31 100644 --- a/extra/rpm/mock/tarantool-fedora-rawhide-i386.cfg +++ b/extra/rpm/mock/tarantool-fedora-rawhide-i386.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-fedora-rawhide-i386' config_opts['target_arch'] = 'i386' config_opts['legal_host_arches'] = ('i386', 'i586', 'i686', 'x86_64') -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'rawhide' # only useful for --resultdir variable subst config_opts['extra_chroot_dirs'] = [ '/run/lock', ] config_opts['releasever'] = '21' diff --git a/extra/rpm/mock/tarantool-fedora-rawhide-x86_64.cfg b/extra/rpm/mock/tarantool-fedora-rawhide-x86_64.cfg index e15f95a4675f3b1a495a3104d2dc04feae0fa017..136c221dc86dc3c727e7b058a6981de8cc3c31a6 100644 --- a/extra/rpm/mock/tarantool-fedora-rawhide-x86_64.cfg +++ b/extra/rpm/mock/tarantool-fedora-rawhide-x86_64.cfg @@ -1,7 +1,7 @@ config_opts['root'] = 'tarantool-fedora-rawhide-x86_64' config_opts['target_arch'] = 'x86_64' config_opts['legal_host_arches'] = ('x86_64',) -config_opts['chroot_setup_cmd'] = 'install @buildsys-build' +config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build' config_opts['dist'] = 'rawhide' # only useful for --resultdir variable subst config_opts['extra_chroot_dirs'] = [ '/run/lock', ] config_opts['releasever'] = '21' diff --git a/extra/rpm/tarantool.rpm.spec.in b/extra/rpm/tarantool.rpm.spec.in index 7eea1b54109c32ff49f26d20b00e14eb75d69788..96cbdb18e3d41851ca379f4f757271f7bf493e05 100644 --- a/extra/rpm/tarantool.rpm.spec.in +++ b/extra/rpm/tarantool.rpm.spec.in @@ -65,6 +65,7 @@ License: BSD Requires: readline Provides: %{?scl_prefix}tarantool-debuginfo Provides: %{?scl_prefix}tarantool-debug +Requires: %{?scl_prefix}tarantool-common URL: http://tarantool.org Source0: @RPM_PACKAGE_SOURCE_FILE_NAME@ %description @@ -86,11 +87,27 @@ It supports replication, online backup, stored procedures in Lua. This package provides Tarantool client libraries. +%package common +Summary: Tarantool common files +Vendor: tarantool.org +Group: Applications/Databases +Provides: %{?scl_prefix}tarantool-common +%if 0%{?rhel} != 5 +BuildArch: noarch +%endif +Requires: %{?scl_prefix}tarantool +%description common +Tarantool is a high performance in-memory NoSQL database. +It supports replication, online backup, stored procedures in Lua. + +This package provides common files + # Tarantool sql module %package sql-module Summary: Tarantool common sql interface Vendor: tarantool.org Group: Applications/Databases +Requires: %{?scl_prefix}tarantool = @RPM_PACKAGE_VERSION@-@RPM_PACKAGE_RELEASE@ %description sql-module Tarantool is a high performance in-memory NoSQL database. It supports replication, online backup, stored procedures in Lua. @@ -100,12 +117,13 @@ tarantool-pg-module or by tarantool-mysql-module. %if %{with postgresql} %package pg-module -Summary: Tarantool common sql interface +Summary: Tarantool PostgreSQL interface Vendor: tarantool.org Group: Applications/Databases Provides: %{?scl_prefix}tarantool-pg-module BuildRequires: postgresql-devel >= 9.0 Requires: postgresql-libs >= 9.0 +Requires: %{?scl_prefix}tarantool = @RPM_PACKAGE_VERSION@-@RPM_PACKAGE_RELEASE@ %description pg-module Tarantool is a high performance in-memory NoSQL database. It supports replication, online backup, stored procedures in Lua. @@ -116,12 +134,13 @@ tarantool-sql-module. %if %{with mysql} %package mysql-module -Summary: Tarantool common sql interface +Summary: Tarantool MySQL interface Vendor: tarantool.org Group: Applications/Databases Provides: %{?scl_prefix}tarantool-mysql-module BuildRequires: mysql-devel >= 5.0 Requires: mysql-libs >= 5.0 +Requires: %{?scl_prefix}tarantool = @RPM_PACKAGE_VERSION@-@RPM_PACKAGE_RELEASE@ %description mysql-module Tarantool is a high performance in-memory NoSQL database. It supports replication, online backup, stored procedures in Lua. @@ -209,7 +228,7 @@ make VERBOSE=1 DESTDIR=%{buildroot} install -c "Tarantool Server" tarantool > /dev/null 2>&1 || : %endif -%post +%post common mkdir -m 0755 -p %{_var}/run/tarantool/ chown tarantool:tarantool %{_var}/run/tarantool/ mkdir -m 0755 -p %{_var}/log/tarantool/ @@ -218,6 +237,7 @@ mkdir -m 0755 -p %{_var}/lib/tarantool/ chown tarantool:tarantool %{_var}/lib/tarantool/ mkdir -m 0755 -p %{_sysconfdir}/tarantool/instances.enabled/ mkdir -m 0755 -p %{_sysconfdir}/tarantool/instances.available/ + %if %{with systemd} %systemd_post tarantool.service %else @@ -225,7 +245,7 @@ chkconfig --add tarantool /sbin/service tarantool start %endif -%preun +%preun common %if %{with systemd} %systemd_preun tarantool.service %else @@ -233,10 +253,10 @@ chkconfig --add tarantool chkconfig --del tarantool %endif -# %%postun -# %%if %%{with systemd} -# %%systemd_postun_with_restart tarantool.service -# %%endif +%postun common +%if %{with systemd} +%systemd_postun_with_restart tarantool.service +%endif %files %defattr(-,root,root,-) @@ -249,18 +269,6 @@ chkconfig --del tarantool "%{_mandir}/man1/tarantool.1.gz" -"%{_sysconfdir}/sysconfig/tarantool" - -%if %{with systemd} -"%{_unitdir}/tarantool.service" -"%{_libdir}/tarantool/tarantool.init" -%else -"%{_sysconfdir}/init.d/tarantool" -%endif - -%dir "%{_libdir}/tarantool/" -"%{_bindir}/tarantoolctl" - %files sql-module %defattr(-,root,root,-) %dir "%{_datadir}/tarantool" @@ -293,6 +301,19 @@ chkconfig --del tarantool "%{_includedir}/tarantool/luajit.h" "%{_includedir}/tarantool/lualib.h" +%files common +%defattr(-,root,root,-) +%dir "%{_libdir}/tarantool/" +"%{_bindir}/tarantoolctl" +"%{_mandir}/man1/tarantoolctl.1.gz" +"%{_sysconfdir}/sysconfig/tarantool" +%if %{with systemd} +"%{_unitdir}/tarantool.service" +"%{_libdir}/tarantool/tarantool.init" +%else +"%{_sysconfdir}/init.d/tarantool" +%endif + %changelog * Fri Jun 06 2014 Eugine Blikh <bigbes@tarantool.org> 1.0-2 - Add SCL support diff --git a/extra/schema_erase.lua b/extra/schema_erase.lua index 56d773df5fc079f08fee5c178b32d7a135289310..3593cbb1ae4f3f439bb16ed89990e6009bd17733 100644 --- a/extra/schema_erase.lua +++ b/extra/schema_erase.lua @@ -6,21 +6,31 @@ _func = box.space[box.schema.FUNC_ID] _priv = box.space[box.schema.PRIV_ID] _cluster = box.space[box.schema.CLUSTER_ID] -- destroy everything - save snapshot produces an empty snapshot now -_schema:run_triggers(false) -_schema:truncate() + +-- space:truncate() doesn't work with disabled triggers on __index +local function truncate(space) + local pk = space.index[0] + while pk:len() > 0 do + local state, t + for state, t in pk:pairs() do + local key = {} + for _k2, parts in ipairs(pk.parts) do + table.insert(key, t[parts.fieldno]) + end + space:delete(key) + end + end +end + _space:run_triggers(false) -_space:truncate() _index:run_triggers(false) -_index:truncate() _user:run_triggers(false) -_user:truncate() _func:run_triggers(false) -_func:truncate() _priv:run_triggers(false) -_priv:truncate() -_cluster:run_triggers(false) --- select server id 1 - self -t = _cluster:get{1} -_cluster:truncate() --- preserve self-identification -_cluster:insert(t) + +truncate(_space) +truncate(_index) +truncate(_user) +truncate(_func) +truncate(_priv) +_schema:delete('version') diff --git a/src/box/access.cc b/src/box/access.cc index d4437c94a16c2047925d796fcdc4b535a8851c5f..1521b5f6e4a8f4557a4df1db829659034f60b8eb 100644 --- a/src/box/access.cc +++ b/src/box/access.cc @@ -98,6 +98,7 @@ user_cache_replace(struct user *user) old->auth_token = auth_token; } user->auth_token = old->auth_token; + user->universal_access = old->universal_access; *old = *user; struct mh_i32ptr_node_t node = { old->uid, old }; mh_i32ptr_put(user_registry, &node, NULL, NULL); diff --git a/src/box/alter.cc b/src/box/alter.cc index 43441d7b004d750b3687fdea791e7cd62d4fbf31..7a1b19296c1c352d9e5d9a5ad0055d520f68bef1 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -214,13 +214,13 @@ AlterSpaceOp::destroy(AlterSpaceOp *op) * A trigger installed on transaction commit/rollback events of * the transaction which initiated the alter. */ -struct trigger * -txn_alter_trigger_new(trigger_f run, struct alter_space *alter) +static struct trigger * +txn_alter_trigger_new(trigger_f run, void *data) { struct trigger *trigger = (struct trigger *) region_alloc0(&fiber()->gc, sizeof(*trigger)); trigger->run = run; - trigger->data = alter; + trigger->data = data; trigger->destroy = NULL; return trigger; } @@ -438,7 +438,7 @@ alter_space_do(struct txn *txn, struct alter_space *alter, * Create a new (empty) space for the new definition. * Sic: the space engine is not the same yet, the * triggers are not set. - */ + */ alter->new_space = space_new(&alter->space_def, &alter->key_list); /* * Copy the engine, the new space is at the same recovery @@ -659,15 +659,6 @@ ModifyIndex::~ModifyIndex() * * The trigger is removed when alter operation commits/rolls back. */ -struct trigger * -add2index_trigger_new(trigger_f run, Index *new_index) -{ - struct trigger *trigger = (struct trigger *) - region_alloc0(&fiber()->gc, sizeof(*trigger)); - trigger->run = run; - trigger->data = new_index; - return trigger; -} /** AddIndex - add a new index to the space. */ class AddIndex: public AlterSpaceOp { @@ -761,7 +752,7 @@ on_replace_in_old_space(struct trigger *trigger, void *event) * creating the trigger may fail. */ struct trigger *on_rollback = - add2index_trigger_new(on_rollback_in_old_space, new_index); + txn_alter_trigger_new(on_rollback_in_old_space, new_index); /* * In a multi-statement transaction the same space * may be modified many times, but we need only one @@ -877,7 +868,7 @@ AddIndex::alter(struct alter_space *alter) assert(old_tuple == NULL); /* Guaranteed by DUP_INSERT. */ (void) old_tuple; } - on_replace = add2index_trigger_new(on_replace_in_old_space, + on_replace = txn_alter_trigger_new(on_replace_in_old_space, new_index); trigger_add(&alter->old_space->on_replace, on_replace); } @@ -912,9 +903,6 @@ on_drop_space(struct trigger * /* trigger */, void *event) space_delete(space); } -static struct trigger drop_space_trigger = - { rlist_nil, on_drop_space, NULL, NULL }; - /** * A trigger which is invoked on replace in a data dictionary * space _space. @@ -1007,7 +995,9 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event) * so it's safe to simply drop the space on * rollback. */ - trigger_add(&txn->on_rollback, &drop_space_trigger); + struct trigger *on_rollback = + txn_alter_trigger_new(on_drop_space, NULL); + trigger_add(&txn->on_rollback, on_rollback); } else if (new_tuple == NULL) { /* DELETE */ access_check_ddl(old_space->def.uid); /* Verify that the space is empty (has no indexes) */ @@ -1026,7 +1016,9 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event) * dd_space_delete() can't fail, any such * failure would have to abort the server. */ - trigger_add(&txn->on_commit, &drop_space_trigger); + struct trigger *on_commit = + txn_alter_trigger_new(on_drop_space, NULL); + trigger_add(&txn->on_commit, on_commit); } else { /* UPDATE, REPLACE */ assert(old_space != NULL && new_tuple != NULL); /* @@ -1255,9 +1247,6 @@ user_cache_remove_user(struct trigger * /* trigger */, void *event) user_cache_delete(uid); } -static struct trigger drop_user_trigger = - { rlist_nil, user_cache_remove_user, NULL, NULL }; - static void user_cache_alter_user(struct trigger * /* trigger */, void *event) { @@ -1268,9 +1257,6 @@ user_cache_alter_user(struct trigger * /* trigger */, void *event) user_cache_replace(&user); } -static struct trigger modify_user_trigger = - { rlist_nil, user_cache_alter_user, NULL, NULL }; - /** * A trigger invoked on replace in the user table. */ @@ -1290,7 +1276,9 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event) struct user user; user_create_from_tuple(&user, new_tuple); (void) user_cache_replace(&user); - trigger_add(&txn->on_rollback, &drop_user_trigger); + struct trigger *on_rollback = + txn_alter_trigger_new(user_cache_remove_user, NULL); + trigger_add(&txn->on_rollback, on_rollback); } else if (new_tuple == NULL) { /* DELETE */ access_check_ddl(old_user->owner); /* Can't drop guest or super user */ @@ -1307,7 +1295,9 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event) tnt_raise(ClientError, ER_DROP_USER, old_user->name, "the user has objects"); } - trigger_add(&txn->on_commit, &drop_user_trigger); + struct trigger *on_commit = + txn_alter_trigger_new(user_cache_remove_user, NULL); + trigger_add(&txn->on_commit, on_commit); } else { /* UPDATE, REPLACE */ assert(old_user != NULL && new_tuple != NULL); /* @@ -1317,7 +1307,9 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event) */ struct user user; user_create_from_tuple(&user, new_tuple); - trigger_add(&txn->on_commit, &modify_user_trigger); + struct trigger *on_commit = + txn_alter_trigger_new(user_cache_alter_user, NULL); + trigger_add(&txn->on_commit, on_commit); } } @@ -1353,9 +1345,6 @@ func_cache_remove_func(struct trigger * /* trigger */, void *event) func_cache_delete(fid); } -static struct trigger drop_func_trigger = - { rlist_nil, func_cache_remove_func, NULL, NULL }; - /** Replace a function in the function cache */ static void func_cache_replace_func(struct trigger * /* trigger */, void *event) @@ -1366,9 +1355,6 @@ func_cache_replace_func(struct trigger * /* trigger */, void *event) func_cache_replace(&func); } -static struct trigger modify_func_trigger = - { rlist_nil, func_cache_replace_func, NULL, NULL }; - /** * A trigger invoked on replace in a space containing * functions on which there were defined any grants. @@ -1389,7 +1375,9 @@ on_replace_dd_func(struct trigger * /* trigger */, void *event) if (new_tuple != NULL && old_func == NULL) { /* INSERT */ func_def_create_from_tuple(&func, new_tuple); func_cache_replace(&func); - trigger_add(&txn->on_rollback, &drop_func_trigger); + struct trigger *on_rollback = + txn_alter_trigger_new(func_cache_remove_func, NULL); + trigger_add(&txn->on_rollback, on_rollback); } else if (new_tuple == NULL) { /* DELETE */ func_def_create_from_tuple(&func, old_tuple); /* @@ -1403,11 +1391,15 @@ on_replace_dd_func(struct trigger * /* trigger */, void *event) (unsigned) func.uid, "function has grants"); } - trigger_add(&txn->on_commit, &drop_func_trigger); + struct trigger *on_commit = + txn_alter_trigger_new(func_cache_remove_func, NULL); + trigger_add(&txn->on_commit, on_commit); } else { /* UPDATE, REPLACE */ func_def_create_from_tuple(&func, new_tuple); access_check_ddl(func.uid); - trigger_add(&txn->on_commit, &modify_func_trigger); + struct trigger *on_commit = + txn_alter_trigger_new(func_cache_replace_func, NULL); + trigger_add(&txn->on_commit, on_commit); } } @@ -1533,9 +1525,6 @@ revoke_priv(struct trigger * /* trigger */, void *event) grant_or_revoke(&priv); } -static struct trigger revoke_priv_trigger = - { rlist_nil, revoke_priv, NULL, NULL }; - /** A trigger called on rollback of grant, or on commit of revoke. */ static void modify_priv(struct trigger * /* trigger */, void *event) @@ -1546,9 +1535,6 @@ modify_priv(struct trigger * /* trigger */, void *event) grant_or_revoke(&priv); } -static struct trigger modify_priv_trigger = - { rlist_nil, modify_priv, NULL, NULL }; - /** * A trigger invoked on replace in the space containing * all granted privileges. @@ -1566,16 +1552,22 @@ on_replace_dd_priv(struct trigger * /* trigger */, void *event) priv_def_create_from_tuple(&priv, new_tuple); priv_def_check(&priv); grant_or_revoke(&priv); - trigger_add(&txn->on_rollback, &revoke_priv_trigger); + struct trigger *on_rollback = + txn_alter_trigger_new(revoke_priv, NULL); + trigger_add(&txn->on_rollback, on_rollback); } else if (new_tuple == NULL) { /* revoke */ assert(old_tuple); priv_def_create_from_tuple(&priv, old_tuple); access_check_ddl(priv.grantor_id); - trigger_add(&txn->on_commit, &revoke_priv_trigger); + struct trigger *on_commit = + txn_alter_trigger_new(revoke_priv, NULL); + trigger_add(&txn->on_commit, on_commit); } else { /* modify */ priv_def_create_from_tuple(&priv, new_tuple); priv_def_check(&priv); - trigger_add(&txn->on_commit, &modify_priv_trigger); + struct trigger *on_commit = + txn_alter_trigger_new(modify_priv, NULL); + trigger_add(&txn->on_commit, on_commit); } } @@ -1655,9 +1647,6 @@ on_commit_dd_cluster(struct trigger *trigger, void *event) cluster_set_server(&uuid, id); } -static struct trigger commit_cluster_trigger = - { rlist_nil, on_commit_dd_cluster, NULL, NULL }; - /** * A trigger invoked on replace in the space _cluster, * which contains cluster configuration. @@ -1684,22 +1673,21 @@ on_replace_dd_cluster(struct trigger *trigger, void *event) txn_check_autocommit(txn, "Space _cluster"); struct txn_stmt *stmt = txn_stmt(txn); struct tuple *new_tuple = stmt->new_tuple; - if (new_tuple == NULL) { - trigger_add(&txn->on_commit, &commit_cluster_trigger); - return; + if (new_tuple != NULL) { + /* Check fields */ + uint32_t server_id = tuple_field_u32(new_tuple, 0); + if (cserver_id_is_reserved(server_id)) + tnt_raise(ClientError, ER_SERVER_ID_IS_RESERVED, + (unsigned) server_id); + tt_uuid server_uuid = tuple_field_uuid(new_tuple, 1); + if (tt_uuid_is_nil(&server_uuid)) + tnt_raise(ClientError, ER_INVALID_UUID, + tt_uuid_str(&server_uuid)); } - /* Check fields */ - uint32_t server_id = tuple_field_u32(new_tuple, 0); - if (cserver_id_is_reserved(server_id)) - tnt_raise(ClientError, ER_SERVER_ID_IS_RESERVED, - (unsigned) server_id); - tt_uuid server_uuid = tuple_field_uuid(new_tuple, 1); - if (tt_uuid_is_nil(&server_uuid)) - tnt_raise(ClientError, ER_INVALID_UUID, - tt_uuid_str(&server_uuid)); - - trigger_add(&txn->on_commit, &commit_cluster_trigger); + struct trigger *on_commit = + txn_alter_trigger_new(on_commit_dd_cluster, NULL); + trigger_add(&txn->on_commit, on_commit); } /* }}} cluster configuration */ diff --git a/src/box/box.cc b/src/box/box.cc index fbe75d450ff8d29086a08ff46dca689c00b996ed..5f079c7e811580fecec6fc870c593077dc56f2ba 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -58,6 +58,8 @@ static void process_ro(struct port *port, struct request *request); static void process_rw(struct port *port, struct request *request); box_process_func box_process = process_ro; +struct recovery_state *recovery; + static int stat_base; int snapshot_pid = 0; /* snapshot processes pid */ @@ -107,8 +109,11 @@ box_is_ro(void) } static void -recover_row(void *param __attribute__((unused)), struct xrow_header *row) +recover_row(struct recovery_state *r, void *param, struct xrow_header *row) { + (void) param; + (void) r; + assert(r == recovery); assert(row->bodycnt == 1); /* always 1 for read */ struct request request; request_create(&request, row->type); @@ -324,6 +329,26 @@ box_on_cluster_join(const tt_uuid *server_uuid) (unsigned) server_id, tt_uuid_str(server_uuid)); } +void +box_process_join(struct xrow_header *header) +{ + assert(header->type == IPROTO_JOIN); + struct tt_uuid server_uuid = uuid_nil; + xrow_decode_join(header, &server_uuid); + + box_on_cluster_join(&server_uuid); + + /* process JOIN request via replication relay */ + replication_join(session()->fd, header); +} + +void +box_process_subscribe(struct xrow_header *header) +{ + /* process SUBSCRIBE request via replication relay */ + replication_subscribe(session()->fd, header); +} + /** Replace the current server id in _cluster */ static void box_set_server_uuid() @@ -356,10 +381,13 @@ box_set_cluster_uuid() void box_free(void) { + if (recovery == NULL) + return; user_cache_free(); schema_free(); tuple_free(); - recovery_free(); + recovery_delete(recovery); + recovery = NULL; engine_shutdown(); stat_free(); session_free(); @@ -396,9 +424,8 @@ box_init() user_cache_init(); /* recovery initialization */ - recovery_init(cfg_gets("snap_dir"), cfg_gets("wal_dir"), - recover_row, NULL, box_snapshot_cb, box_on_cluster_join, - cfg_geti("rows_per_wal")); + recovery = recovery_new(cfg_gets("snap_dir"), cfg_gets("wal_dir"), + recover_row, NULL, box_snapshot_cb, cfg_geti("rows_per_wal")); recovery_set_remote(recovery, cfg_gets("replication_source")); recovery_update_io_rate_limit(recovery, cfg_getd("snap_io_rate_limit")); @@ -450,6 +477,15 @@ box_init() iobuf_set_readahead(cfg_geti("readahead")); } + +void +box_atfork() +{ + if (recovery == NULL) + return; + recovery_atfork(recovery); +} + static void snapshot_write_tuple(struct log_io *l, uint32_t n, struct tuple *tuple) @@ -470,7 +506,7 @@ snapshot_write_tuple(struct log_io *l, row.body[0].iov_len = sizeof(body); row.body[1].iov_base = tuple->data; row.body[1].iov_len = tuple->bsize; - snapshot_write_row(l, &row); + snapshot_write_row(recovery, l, &row); } static void diff --git a/src/box/box.h b/src/box/box.h index 3658142c85d13197c062b13f615177b5258b6b1b..a2ebc2f28912092ab442fe9d7ac43e815ab01b23 100644 --- a/src/box/box.h +++ b/src/box/box.h @@ -52,6 +52,10 @@ void box_init(); /** To be called at program end. */ void box_free(void); +/** A pthread_atfork() callback for box */ +void +box_atfork(); + /** * The main entry point to the * Box: callbacks into the request processor. @@ -96,6 +100,12 @@ const char *box_status(void); void box_leave_local_standby_mode(void *data __attribute__((unused))); +void +box_process_join(struct xrow_header *header); + +void +box_process_subscribe(struct xrow_header *header); + /** * Check Lua configuration before initialization or * in case of a configuration change. @@ -112,6 +122,8 @@ void box_set_io_collect_interval(double interval); void box_set_snap_io_rate_limit(double limit); void box_set_too_long_threshold(double threshold); +extern struct recovery_state *recovery; + #if defined(__cplusplus) } #endif /* defined(__cplusplus) */ diff --git a/src/box/engine_sophia.cc b/src/box/engine_sophia.cc index c5df41b195268b4490c7a42bb691ee45e224415e..20a9555196e7656f493456181535adde9e14d226 100644 --- a/src/box/engine_sophia.cc +++ b/src/box/engine_sophia.cc @@ -29,6 +29,7 @@ #include "cfg.h" #include "txn.h" #include "tuple.h" +#include "scoped_guard.h" #include "engine.h" #include "engine_sophia.h" #include "index.h" @@ -45,7 +46,15 @@ #include <dirent.h> #include <errno.h> -extern "C" void *sp_error(void *o, ...); +void sophia_raise(void *env) +{ + void *c = sp_ctl(env); + void *o = sp_get(c, "sophia.error"); + char *error = (char *)sp_get(o, "value", NULL); + auto scoped_guard = + make_scoped_guard([=] { sp_destroy(o); }); + tnt_raise(ClientError, ER_SOPHIA, error); +} struct Sophia: public Engine { Sophia(EngineFactory*); @@ -98,7 +107,7 @@ SophiaFactory::init() panic("failed to create sophia environment"); int rc = sp_open(env); if (rc == -1) - tnt_raise(ClientError, ER_SOPHIA, sp_error(env)); + sophia_raise(env); } Engine* @@ -161,7 +170,7 @@ SophiaFactory::dropIndex(Index *index) SophiaIndex *i = (SophiaIndex*)index; int rc = sp_destroy(i->db); if (rc == -1) - tnt_raise(ClientError, ER_SOPHIA, sp_error(i->db)); + sophia_raise(env); i->db = NULL; i->env = NULL; char path[PATH_MAX]; diff --git a/src/box/engine_sophia.h b/src/box/engine_sophia.h index 3bb0bc0d544dd98d43fbb481c5f48e554366a3a7..d29f50ba87a9c9153975f1697d7caef77287a1c6 100644 --- a/src/box/engine_sophia.h +++ b/src/box/engine_sophia.h @@ -41,4 +41,6 @@ struct SophiaFactory: public EngineFactory { void *env; }; +void sophia_raise(void*); + #endif /* TARANTOOL_BOX_ENGINE_SOPHIA_H_INCLUDED */ diff --git a/src/box/iproto.cc b/src/box/iproto.cc index 512d11f0b43a1f5b9de7661b1d94edd88b5b7de8..0c2470153e45f8f6d8e5cf9a6cac2d79ad3e5974 100644 --- a/src/box/iproto.cc +++ b/src/box/iproto.cc @@ -42,7 +42,6 @@ #include "scoped_guard.h" #include "memory.h" #include "msgpuck/msgpuck.h" -#include "replication.h" #include "session.h" #include "third_party/base64.h" #include "coio.h" @@ -710,12 +709,12 @@ iproto_process_admin(struct iproto_request *ireq) ireq->header.sync); break; case IPROTO_JOIN: - replication_join(con->input.fd, &ireq->header); + box_process_join(&ireq->header); /* TODO: check requests in `con; queue */ iproto_connection_shutdown(con); return; case IPROTO_SUBSCRIBE: - replication_subscribe(con->input.fd, &ireq->header); + box_process_subscribe(&ireq->header); /* TODO: check requests in `con; queue */ iproto_connection_shutdown(con); return; diff --git a/src/box/recovery.cc b/src/box/recovery.cc index e782e96bf8cd11a01a5713ca83a1f1e8be48ddfb..e39be264d3d208425eacaa356b4b01ce4263a7cc 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -111,8 +111,6 @@ * R -> S # snapshot() */ -struct recovery_state *recovery; - const char *wal_mode_STRS[] = { "none", "write", "fsync", NULL }; /* {{{ LSN API */ @@ -152,15 +150,14 @@ wal_writer_stop(struct recovery_state *r); static void recovery_stop_local(struct recovery_state *r); -void -recovery_init(const char *snap_dirname, const char *wal_dirname, - row_handler row_handler, void *row_handler_param, - snapshot_handler snapshot_handler, join_handler join_handler, - int rows_per_wal) +struct recovery_state * +recovery_new(const char *snap_dirname, const char *wal_dirname, + row_handler row_handler, void *row_handler_param, + snapshot_handler snapshot_handler, + int rows_per_wal) { - assert(recovery == NULL); - recovery = (struct recovery_state *) calloc(1, sizeof(struct recovery_state)); - struct recovery_state *r = recovery; + struct recovery_state *r = (struct recovery_state *) + calloc(1, sizeof(*r)); recovery_update_mode(r, WAL_NONE); assert(rows_per_wal > 1); @@ -170,7 +167,6 @@ recovery_init(const char *snap_dirname, const char *wal_dirname, r->signature = -1; r->snapshot_handler = snapshot_handler; - r->join_handler = join_handler; log_dir_create(&r->snap_dir, snap_dirname, SNAP); @@ -187,6 +183,8 @@ recovery_init(const char *snap_dirname, const char *wal_dirname, panic("can't scan snapshot directory"); if (log_dir_scan(&r->wal_dir) != 0) panic("can't scan WAL directory"); + + return r; } void @@ -205,12 +203,8 @@ recovery_update_io_rate_limit(struct recovery_state *r, double new_limit) } void -recovery_free() +recovery_delete(struct recovery_state *r) { - struct recovery_state *r = recovery; - if (r == NULL) - return; - if (r->watcher) recovery_stop_local(r); @@ -226,7 +220,6 @@ recovery_free() */ log_io_close(&r->current_wal); } - recovery= NULL; } void @@ -247,7 +240,7 @@ recovery_process(struct recovery_state *r, struct xrow_header *row) return; } - return r->row_handler(r->row_handler_param, row); + return r->row_handler(r, r->row_handler_param, row); } void @@ -683,8 +676,6 @@ struct wal_writer struct vclock vclock; }; -static pthread_once_t wal_writer_once = PTHREAD_ONCE_INIT; - static struct wal_writer wal_writer; /** @@ -692,31 +683,22 @@ static struct wal_writer wal_writer; * fork the master process to save a snapshot, and in the child * the WAL writer thread is not necessary and not present. */ -static void -wal_writer_child() +void +recovery_atfork(struct recovery_state *r) { - log_io_atfork(&recovery->current_wal); - if (wal_writer.batch) { - free(wal_writer.batch); - wal_writer.batch = NULL; + log_io_atfork(&r->current_wal); + if (r->writer == NULL) + return; + if (r->writer->batch) { + free(r->writer->batch); + r->writer->batch = NULL; } /* * Make sure that atexit() handlers in the child do * not try to stop the non-existent thread. * The writer is not used in the child. */ - recovery->writer = NULL; -} - -/** - * Today a WAL writer is started once at start of the - * server. Nevertheless, use pthread_once() to make - * sure we can start/stop the writer many times. - */ -static void -wal_writer_init_once() -{ - (void) tt_pthread_atfork(NULL, NULL, wal_writer_child); + r->writer = NULL; } /** @@ -802,8 +784,6 @@ wal_writer_init(struct wal_writer *writer, struct vclock *vclock) writer->write_event.data = writer; writer->txn_loop = loop(); - (void) tt_pthread_once(&wal_writer_once, wal_writer_init_once); - writer->batch = fio_batch_alloc(sysconf(_SC_IOV_MAX)); if (writer->batch == NULL) @@ -1118,13 +1098,13 @@ wal_write(struct recovery_state *r, struct xrow_header *row) /* {{{ box.snapshot() */ void -snapshot_write_row(struct log_io *l, struct xrow_header *row) +snapshot_write_row(struct recovery_state *r, struct log_io *l, + struct xrow_header *row) { static uint64_t bytes; ev_tstamp elapsed; static ev_tstamp last = 0; ev_loop *loop = loop(); - struct recovery_state *r = recovery; row->tm = last; row->server_id = 0; diff --git a/src/box/recovery.h b/src/box/recovery.h index 60fff69fa0e90325a6225b310dac179d52a17d9e..e982d8291bcc8b1801cdac8e48a8cb4bb2a32f79 100644 --- a/src/box/recovery.h +++ b/src/box/recovery.h @@ -44,10 +44,11 @@ extern "C" { struct fiber; struct tbuf; +struct recovery_state; -typedef void (row_handler)(void *, struct xrow_header *packet); +typedef void (row_handler)(struct recovery_state *, void *, + struct xrow_header *packet); typedef void (snapshot_handler)(struct log_io *); -typedef void (join_handler)(const struct tt_uuid *node_uuid); /** A "condition variable" that allows fibers to wait when a given * LSN makes it to disk. @@ -81,7 +82,6 @@ struct recovery_state { row_handler *row_handler; void *row_handler_param; snapshot_handler *snapshot_handler; - join_handler *join_handler; uint64_t snap_io_rate_limit; int rows_per_wal; enum wal_mode wal_mode; @@ -91,16 +91,21 @@ struct recovery_state { bool finalize; }; -extern struct recovery_state *recovery; +struct recovery_state * +recovery_new(const char *snap_dirname, const char *wal_dirname, + row_handler row_handler, void *row_handler_param, + snapshot_handler snapshot_handler, + int rows_per_wal); + +void +recovery_delete(struct recovery_state *r); + +void +recovery_atfork(struct recovery_state *r); -void recovery_init(const char *snap_dirname, const char *xlog_dirname, - row_handler row_handler, void *row_handler_param, - snapshot_handler snapshot_handler, join_handler join_handler, - int rows_per_wal); void recovery_update_mode(struct recovery_state *r, enum wal_mode mode); void recovery_update_io_rate_limit(struct recovery_state *r, double new_limit); -void recovery_free(); static inline bool recovery_has_data(struct recovery_state *r) @@ -122,7 +127,8 @@ void recovery_process(struct recovery_state *r, struct xrow_header *packet); struct fio_batch; void -snapshot_write_row(struct log_io *l, struct xrow_header *packet); +snapshot_write_row(struct recovery_state *r, struct log_io *l, + struct xrow_header *packet); void snapshot_save(struct recovery_state *r); #if defined(__cplusplus) diff --git a/src/box/replication.cc b/src/box/replication.cc index 295c1335149688d456629ef3417225588103a4ef..d37940c43ed7b9a44cbf5390bb7ce5dd0726a827 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -30,7 +30,6 @@ #include <say.h> #include <fiber.h> #include <stddef.h> - #include <stddef.h> #include <sys/types.h> #include <sys/socket.h> @@ -215,13 +214,6 @@ struct replication_request { void replication_join(int fd, struct xrow_header *packet) { - assert(packet->type == IPROTO_JOIN); - struct tt_uuid server_uuid = uuid_nil; - xrow_decode_join(packet, &server_uuid); - - /* Notify box about new cluster server */ - recovery->join_handler(&server_uuid); - struct replication_request *request = (struct replication_request *) malloc(sizeof(*request)); if (request == NULL) { @@ -636,10 +628,10 @@ replication_relay_recv(ev_loop * /* loop */, struct ev_io *w, int __attribute__( /** Send a single row to the client. */ static void -replication_relay_send_row(void * /* param */, struct xrow_header *packet) +replication_relay_send_row(struct recovery_state *r, void * /* param */, + struct xrow_header *packet) { assert(iproto_type_is_dml(packet->type)); - struct recovery_state *r = recovery; /* Don't duplicate data */ if (packet->server_id == 0 || packet->server_id != r->server_id) { @@ -749,24 +741,25 @@ replication_relay_loop() sio_setfl(relay.sock, O_NONBLOCK, 0); /* Initialize the recovery process */ - recovery_init(cfg_snap_dir, cfg_wal_dir, + struct recovery_state *r = recovery_new(cfg_snap_dir, cfg_wal_dir, replication_relay_send_row, - NULL, NULL, NULL, INT32_MAX); - + NULL, NULL, INT32_MAX); + int rc = EXIT_SUCCESS; try { switch (relay.type) { case IPROTO_JOIN: - replication_relay_join(recovery); + replication_relay_join(r); break; case IPROTO_SUBSCRIBE: - replication_relay_subscribe(recovery); + replication_relay_subscribe(r); break; default: assert(false); } } catch (Exception *e) { say_error("relay error: %s", e->errmsg()); - exit(EXIT_FAILURE); + rc = EXIT_FAILURE; } - exit(EXIT_SUCCESS); + recovery_delete(r); + exit(rc); } diff --git a/src/box/schema.cc b/src/box/schema.cc index 5ad3637e0f39e394a6a8fb2582759588666cbc47..fb9a9144de646400cf6e07d8b1d52b736f11b198 100644 --- a/src/box/schema.cc +++ b/src/box/schema.cc @@ -326,12 +326,6 @@ space_end_recover_snapshot() space_foreach(do_one_recover_step, NULL); } -static void -fix_lua(struct space *space, void * /* param */) -{ - box_lua_space_new(tarantool_L, space); -} - static inline void space_end_recover_cb(EngineFactory *f, void *udate) { @@ -349,9 +343,6 @@ space_end_recover() engine_foreach(space_end_recover_cb, NULL); space_foreach(do_one_recover_step, NULL); - - /* TODO: temporary solution for Bug#1229709 */ - space_foreach(fix_lua, NULL); } void diff --git a/src/box/sophia_index.cc b/src/box/sophia_index.cc index 2b62bda4704a937732cada220d8bfc82dbc61def..0fed6226b60096d72e41a3651f8f1f1fa6943ada 100644 --- a/src/box/sophia_index.cc +++ b/src/box/sophia_index.cc @@ -42,10 +42,8 @@ #include <stdio.h> #include <inttypes.h> -extern "C" void *sp_error(void *o, ...); - static inline void -sophia_delete(void *db, struct key_def *key_def, struct tuple *tuple) +sophia_delete(void *env, void *db, struct key_def *key_def, struct tuple *tuple) { const char *key = tuple_field(tuple, key_def->parts[0].fieldno); const char *keyptr = key; @@ -53,15 +51,15 @@ sophia_delete(void *db, struct key_def *key_def, struct tuple *tuple) size_t keysize = keyptr - key; void *o = sp_object(db); if (o == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); sp_set(o, "key", key, keysize); int rc = sp_delete(db, o); if (rc == -1) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); } static inline void -sophia_set(void *db, struct key_def *key_def, struct tuple *tuple) +sophia_set(void *env, void *db, struct key_def *key_def, struct tuple *tuple) { const char *key = tuple_field(tuple, key_def->parts[0].fieldno); const char *keyptr = key; @@ -69,12 +67,12 @@ sophia_set(void *db, struct key_def *key_def, struct tuple *tuple) size_t keysize = keyptr - key; void *o = sp_object(db); if (o == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); sp_set(o, "key", key, keysize); sp_set(o, "value", tuple->data, tuple->bsize); int rc = sp_set(db, o); if (rc == -1) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); } struct tuple * @@ -86,7 +84,6 @@ sophia_replace(struct space *space, return index->replace(old_tuple, new_tuple, mode); } - struct tuple* sophia_replace_recover(struct space *space, struct tuple *old_tuple, struct tuple *new_tuple, @@ -95,10 +92,10 @@ sophia_replace_recover(struct space *space, SophiaIndex *index = (SophiaIndex*)index_find(space, 0); assert(index != NULL); if (old_tuple) { - sophia_delete(index->db, index->key_def, old_tuple); + sophia_delete(index->env, index->db, index->key_def, old_tuple); return NULL; } - sophia_set(index->db, index->key_def, new_tuple); + sophia_set(index->env, index->db, index->key_def, new_tuple); return NULL; } @@ -115,12 +112,13 @@ sophia_index_compare(char *a, size_t asz __attribute__((unused)), } static struct tuple * -sophia_gettuple(void *db, const char *key, size_t keysize, +sophia_gettuple(void *env, void *db, + const char *key, size_t keysize, struct tuple_format *format) { void *o = sp_object(db); if (o == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); sp_set(o, "key", key, keysize); void *result = sp_get(db, o); if (result == NULL) @@ -164,11 +162,11 @@ SophiaIndex::SophiaIndex(struct key_def *key_def_arg __attribute__((unused))) key_def->space_id); db = sp_get(c, name); if (db == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(env)); + sophia_raise(env); sp_destroy(c); int rc = sp_open(db); if (rc == -1) - tnt_raise(ClientError, ER_SOPHIA, sp_error(env)); + sophia_raise(env); tuple_format_ref(space->format, 1); } @@ -180,9 +178,14 @@ SophiaIndex::~SophiaIndex() } if (db) { int rc = sp_destroy(db); - if (rc == -1) - say_info("sophia space %d close error: %s", key_def->space_id, - (char*)sp_error(env)); + if (rc == 0) + return; + void *c = sp_ctl(env); + void *o = sp_get(c, "sophia.error"); + char *error = (char *)sp_get(o, "value", NULL); + say_info("sophia space %d close error: %s", + key_def->space_id, error); + sp_destroy(o); } } @@ -191,11 +194,11 @@ SophiaIndex::random(uint32_t rnd) const { void *o = sp_object(db); if (o == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); sp_set(o, "key", &rnd, sizeof(rnd)); void *c = sp_cursor(db, "random", o); if (c == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); auto scoped_guard = make_scoped_guard([=] { sp_destroy(c); }); o = sp_get(c); @@ -221,14 +224,13 @@ SophiaIndex::size() const { void *c = sp_ctl(env); char name[128]; - snprintf(name, sizeof(name), "db.%" PRIu32 ".profiler.count", + snprintf(name, sizeof(name), "db.%" PRIu32 ".profiler.index_count", key_def->space_id); void *o = sp_get(c, name); if (o == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); uint64_t count = atoi((const char *)sp_get(o, "value", NULL)); sp_destroy(o); - sp_destroy(c); return count; } @@ -237,14 +239,13 @@ SophiaIndex::memsize() const { void *c = sp_ctl(env); char name[128]; - snprintf(name, sizeof(name), "db.%" PRIu32 ".profiler.memory_used", + snprintf(name, sizeof(name), "db.%" PRIu32 ".profiler.index_memory_used", key_def->space_id); void *o = sp_get(c, name); if (o == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); uint64_t used = atoi((const char *)sp_get(o, "value", NULL)); sp_destroy(o); - sp_destroy(c); return used; } @@ -258,7 +259,7 @@ SophiaIndex::findByKey(const char *key, uint32_t part_count) const mp_next(&keyptr); size_t keysize = keyptr - key; struct space *space = space_cache_find(key_def->space_id); - struct tuple *ret = sophia_gettuple(db, key, keysize, space->format); + struct tuple *ret = sophia_gettuple(env, db, key, keysize, space->format); return ret; } @@ -305,7 +306,7 @@ SophiaIndex::replace(struct tuple *old_tuple, struct tuple *new_tuple, struct space *space = space_cache_find(key_def->space_id); struct tuple *dup_tuple = - sophia_gettuple(db, key, keysize, space->format); + sophia_gettuple(env, db, key, keysize, space->format); uint32_t errcode = sophia_check_dup(key_def, old_tuple, dup_tuple, mode); if (errcode) { @@ -318,7 +319,7 @@ SophiaIndex::replace(struct tuple *old_tuple, struct tuple *new_tuple, if (o == NULL) { if (dup_tuple) tuple_unref(dup_tuple); - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); } sp_set(o, "key", key, keysize); sp_set(o, "value", new_tuple->data, new_tuple->bsize); @@ -326,13 +327,13 @@ SophiaIndex::replace(struct tuple *old_tuple, struct tuple *new_tuple, if (rc == -1) { if (dup_tuple) tuple_unref(dup_tuple); - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); } if (dup_tuple) return dup_tuple; } if (old_tuple) - sophia_delete(db, key_def, old_tuple); + sophia_delete(env, db, key_def, old_tuple); return old_tuple; } @@ -342,6 +343,7 @@ struct sophia_iterator { int keysize; uint32_t part_count; struct space *space; + void *env; void *db; void *cursor; }; @@ -396,7 +398,7 @@ sophia_iterator_eq(struct iterator *ptr) ptr->next = sophia_iterator_last; struct sophia_iterator *it = (struct sophia_iterator *) ptr; assert(it->cursor == NULL); - return sophia_gettuple(it->db, it->key, it->keysize, + return sophia_gettuple(it->env, it->db, it->key, it->keysize, it->space->format); } @@ -423,7 +425,6 @@ SophiaIndex::initIterator(struct iterator *ptr, enum iterator_type type, { struct sophia_iterator *it = (struct sophia_iterator *) ptr; assert(it->cursor == NULL); - size_t keysize; if (part_count > 0) { const char *keyptr = key; @@ -436,6 +437,7 @@ SophiaIndex::initIterator(struct iterator *ptr, enum iterator_type type, it->key = key; it->keysize = keysize; it->part_count = part_count; + it->env = env; it->db = db; it->space = space_cache_find(key_def->space_id); const char *compare; @@ -461,12 +463,12 @@ SophiaIndex::initIterator(struct iterator *ptr, enum iterator_type type, if (key) { o = sp_object(db); if (o == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); sp_set(o, "key", key, keysize); } it->cursor = sp_cursor(db, compare, o); if (it->cursor == NULL) - tnt_raise(ClientError, ER_SOPHIA, sp_error(db)); + sophia_raise(env); } /* }}} */ diff --git a/src/box/tuple.cc b/src/box/tuple.cc index bafdf31ff37737d20ace11d8f6377bf1697510a7..b1b873df4d6df227fdccdc1976a1f9e5d96b2e18 100644 --- a/src/box/tuple.cc +++ b/src/box/tuple.cc @@ -544,8 +544,15 @@ tuple_init(float tuple_arena_max_size, uint32_t objsize_min, if (slab_arena_create(&memtx_arena, &memtx_quota, max_size, SLAB_SIZE, flags)) { - panic_syserror("failed to preallocate %zu bytes", - max_size); + if (ENOMEM == errno) { + panic("failed to preallocate %zu bytes: " + "Cannot allocate memory, check option " + "'slab_alloc_arena' in box.cfg(..)", + max_size); + } else { + panic_syserror("failed to preallocate %zu bytes", + max_size); + } } slab_cache_create(&memtx_slab_cache, &memtx_arena, SLAB_SIZE); diff --git a/src/box/txn.cc b/src/box/txn.cc index 180980e2c37d06314ec7ef16dd4718009128a2d5..cd74fae9b773287a5c2d11ac50498f4c510d14b9 100644 --- a/src/box/txn.cc +++ b/src/box/txn.cc @@ -27,6 +27,7 @@ * SUCH DAMAGE. */ #include "txn.h" +#include "box.h" #include "tuple.h" #include "space.h" #include <tarantool.h> diff --git a/src/lib/salad/bps_tree.h b/src/lib/salad/bps_tree.h index 6be1b456e725e71e81aaf8f1da83dd38773acf85..02708a15623e1f1c4c8cabbceeb844ff094b3979 100644 --- a/src/lib/salad/bps_tree.h +++ b/src/lib/salad/bps_tree.h @@ -434,7 +434,7 @@ struct bps_block; (tree)->debug_##type##_branches_mask |= (branch_bit) #else #define BPS_TREE_BRANCH_TRACE(tree, type, branch_bit) \ - do {} while(0) + ((void)0) #endif /** diff --git a/src/lua/box_net_box.lua b/src/lua/box_net_box.lua index b8169e71f58a09859f1952440edc848facfe3b1b..870d049fda884118d19e6d505c402ce3934f7a19 100644 --- a/src/lua/box_net_box.lua +++ b/src/lua/box_net_box.lua @@ -619,21 +619,24 @@ local remote_methods = { local len, off = msgpack.decode(self.rbuf) -- wait for correct package length - if len + off - 1 > #self.rbuf then + local roff = off + len - 1 + if roff > #self.rbuf then break end + local pkt = string.sub(self.rbuf, 1, roff) + self.rbuf = string.sub(self.rbuf, roff + 1) + local hdr, body - hdr, off = msgpack.decode(self.rbuf, off) - if off < #self.rbuf then - body, off = msgpack.decode(self.rbuf, off) + hdr, off = msgpack.decode(pkt, off) + if off <= #pkt then + body, off = msgpack.decode(pkt, off) -- disable YAML flow output (useful for admin console) setmetatable(body, mapping_mt) else body = {} end - self.rbuf = string.sub(self.rbuf, off + 1) local sync = hdr[SYNC] diff --git a/src/lua/tap.lua b/src/lua/tap.lua index 34c4f3fe6012135a9ad3072af70e9f6294742d4e..67cb4026cf86ca7f852bda811e4af8bb58f30d44 100644 --- a/src/lua/tap.lua +++ b/src/lua/tap.lua @@ -126,6 +126,20 @@ local function cmpdeeply(got, expected, extra) return true end +local function like(test, got, pattern, message, extra) + extra = extra or {} + extra.got = got + extra.expected = pattern + return ok(test, string.match(tostring(got), pattern) ~= nil, message, extra) +end + +local function unlike(test, got, pattern, message, extra) + extra = extra or {} + extra.got = got + extra.expected = pattern + return ok(test, string.match(tostring(got), pattern) == nil, message, extra) +end + local function is(test, got, expected, message, extra) extra = extra or {} extra.got = got @@ -141,7 +155,7 @@ local function isnt(test, got, unexpected, message, extra) end -local function isdeeply(test, got, expected, message, extra) +local function is_deeply(test, got, expected, message, extra) extra = extra or {} extra.got = got extra.expected = expected @@ -268,7 +282,9 @@ test_mt = { isboolean = isboolean; isudata = isudata; iscdata = iscdata; - isdeeply = isdeeply; + is_deeply = is_deeply; + like = like; + unlike = unlike; } } diff --git a/src/lua/trigger.cc b/src/lua/trigger.cc index 6ffa2a5ed23a049ba78178ffab7a72303f561f8d..3fafdd1cc42a1ab61f483dfb33f868f3310445c7 100644 --- a/src/lua/trigger.cc +++ b/src/lua/trigger.cc @@ -32,7 +32,9 @@ void lbox_trigger_destroy(struct trigger *trigger) { - luaL_unref(tarantool_L, LUA_REGISTRYINDEX, (intptr_t) trigger->data); + if (tarantool_L) + luaL_unref(tarantool_L, + LUA_REGISTRYINDEX, (intptr_t) trigger->data); free(trigger); } diff --git a/src/say.cc b/src/say.cc index 648f507202ee718f950f69f3ea686911c8908db2..3d213f6f361c6523516e582f0817ac165b5fcd32 100644 --- a/src/say.cc +++ b/src/say.cc @@ -297,7 +297,7 @@ vsay(int level, const char *filename, int line, const char *error, const char *f int r = write(log_fd, buf, p + 1); (void)r; - if (S_FATAL && log_fd != STDERR_FILENO) { + if (level == S_FATAL && log_fd != STDERR_FILENO) { r = write(STDERR_FILENO, buf, p + 1); (void)r; } diff --git a/src/tarantool.cc b/src/tarantool.cc index 1c8873f79583788d267f9099955bb5537c392ca4..5a26d8436f80a2811b4316db60becff69050140b 100644 --- a/src/tarantool.cc +++ b/src/tarantool.cc @@ -265,6 +265,12 @@ signal_reset() say_syserror("sigprocmask"); } +static void +tarantool_atfork() +{ + signal_reset(); + box_atfork(); +} /** * Adjust the process signal mask and add handlers for signals. @@ -303,7 +309,7 @@ signal_init(void) for (int i = 0; i < ev_sig_count; i++) ev_signal_start(loop(), &ev_sigs[i]); - (void) tt_pthread_atfork(NULL, NULL, signal_reset); + (void) tt_pthread_atfork(NULL, NULL, tarantool_atfork); } static void diff --git a/test/app/lua/serializer_test.lua b/test/app/lua/serializer_test.lua index 22f7b028b2668163aa3aedb1efd4be5474c169f6..3adb18518d913d8112c498d3a6ca19aeaa398d13 100644 --- a/test/app/lua/serializer_test.lua +++ b/test/app/lua/serializer_test.lua @@ -18,7 +18,7 @@ local function rt(test, s, x) else xstr = tostring(x) end - test:isdeeply(x, x1, "encode/decode for "..xstr) + test:is_deeply(x, x1, "encode/decode for "..xstr) end local function test_unsigned(test, s) diff --git a/test/app/msgpack.test.lua b/test/app/msgpack.test.lua index b101b361bff04ee2d2d1f8f7196d8f06cbed3073..8fd8b15d8edbb603ee4fa2e59671a627c5404d7f 100755 --- a/test/app/msgpack.test.lua +++ b/test/app/msgpack.test.lua @@ -25,11 +25,11 @@ local function test_offsets(test, s) local a local offset = 1 a, offset = s.decode(dump, offset) - test:isdeeply(a, arr1, "decoded part1") + test:is_deeply(a, arr1, "decoded part1") test:is(offset, 5, "offset of part2") a, offset = s.decode(dump, offset) - test:isdeeply(a, arr2, "decoded part2") + test:is_deeply(a, arr2, "decoded part2") test:is(offset, 9, "offset of end") test:ok(not pcall(s.decode, dump, offset), "invalid offset") diff --git a/test/app/msgpackffi.test.lua b/test/app/msgpackffi.test.lua index 3a9e2fc76477cd7b1459f4cf494420deb86f889e..a3fdf7504b1041778d2bd06aafd07b6346e5db09 100755 --- a/test/app/msgpackffi.test.lua +++ b/test/app/msgpackffi.test.lua @@ -25,11 +25,11 @@ local function test_offsets(test, s) local a local offset = 1 a, offset = s.decode(dump, offset) - test:isdeeply(a, arr1, "decoded part1") + test:is_deeply(a, arr1, "decoded part1") test:is(offset, 5, "offset of part2") a, offset = s.decode(dump, offset) - test:isdeeply(a, arr2, "decoded part2") + test:is_deeply(a, arr2, "decoded part2") test:is(offset, 9, "offset of end") test:ok(not pcall(s.decode, dump, offset), "invalid offset") diff --git a/test/app/tap.result b/test/app/tap.result index a26757e5bf0de39ea0266d114785af85f9dafc64..3e7882331599fad91d2a2f6d2aefa9efa7a62a43 100644 --- a/test/app/tap.result +++ b/test/app/tap.result @@ -1,5 +1,5 @@ TAP version 13 -1..31 +1..32 ok - true ok - extra information is not printed on success not ok - extra printed using yaml only on failure @@ -118,7 +118,7 @@ not ok - failed subtests planned: 1 failed: 1 ... - # isdeeply + # is_deeply 1..6 ok - 1 and 1 ok - abc and abc @@ -136,10 +136,16 @@ not ok - failed subtests expected: 5 got: 4 ... - # isdeeply: end + # is_deeply: end not ok - failed subtests --- planned: 6 failed: 2 ... + # like + 1..2 + ok - like(abcde, cd) + ok - unlike(abcde, acd) + # like: end +ok - like # failed subtest: 15 diff --git a/test/app/tap.test.lua b/test/app/tap.test.lua index cc2d9bf3828395259b466ecc27e284bfd6cdaa62..a823faaa9ced0977fa00253d76442f1a9ca3a8a6 100755 --- a/test/app/tap.test.lua +++ b/test/app/tap.test.lua @@ -20,7 +20,7 @@ test.trace = false -- ok, fail and skip predicates -- -test:plan(31) -- plan to run 3 test +test:plan(32) -- plan to run 3 test test:ok(true, 'true') -- basic function local extra = { state = 'some userful information to debug on failure', details = 'a table argument formatted using yaml.encode()' } @@ -117,18 +117,25 @@ end) -test:test('isdeeply', function(t) +test:test('is_deeply', function(t) t:plan(6) - t:isdeeply(1, 1, '1 and 1') - t:isdeeply('abc', 'abc', 'abc and abc') - t:isdeeply({}, {}, 'empty tables') - t:isdeeply({1}, {1}, '{1} and {1}') - t:isdeeply({1}, {2}, '{1} and {2}') - t:isdeeply({1, 2, { 3, 4 }}, {1, 2, { 3, 5 }}, '{1,2,{3,4}} and {1,2,{3,5}}') + t:is_deeply(1, 1, '1 and 1') + t:is_deeply('abc', 'abc', 'abc and abc') + t:is_deeply({}, {}, 'empty tables') + t:is_deeply({1}, {1}, '{1} and {1}') + t:is_deeply({1}, {2}, '{1} and {2}') + t:is_deeply({1, 2, { 3, 4 }}, {1, 2, { 3, 5 }}, '{1,2,{3,4}} and {1,2,{3,5}}') end) + +test:test('like', function(t) + t:plan(2) + t:like('abcde', 'cd', 'like(abcde, cd)') + t:unlike('abcde', 'acd', 'unlike(abcde, acd)') +end) + -- -- Finish root test. Since we used non-callback variant, we have to -- call check explicitly. diff --git a/test/app/trigger_atexit.result b/test/app/trigger_atexit.result new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/test/app/trigger_atexit.test.lua b/test/app/trigger_atexit.test.lua new file mode 100755 index 0000000000000000000000000000000000000000..1e85558d9effec3aea8b4ae2fcb4bf96ea5a4439 --- /dev/null +++ b/test/app/trigger_atexit.test.lua @@ -0,0 +1,35 @@ +#!/usr/bin/env tarantool +-- vim: set ft=lua : + +-- see https://github.com/tarantool/tarantool/issues/583 + +tap = require 'tap' +fio = require 'fio' +log = require 'log' + +tempdir = fio.tempdir() + +box.cfg { + wal_dir = tempdir, + snap_dir = tempdir, + sophia_dir = tempdir, + logger = fio.pathjoin(tempdir, 'tarantool.log') +} + +local function test_replace(old_tuple, new_tuple) + +end + + +box.schema.create_space('abc') +box.space.abc:create_index('pk', { type = 'tree' }) +box.space.abc:on_replace(test_replace) + + +cleanup_list = fio.glob(fio.pathjoin(tempdir), '*') +for _, file in pairs(cleanup_list) do + fio.unlink(file) +end +fio.rmdir(tempdir) +os.exit(0) + diff --git a/test/box/access_bin.result b/test/box/access_bin.result index 3b2958f0d0afceb16af28f29a888cae66bb33812..1633ab763fe4e8a190c7ebf22d3831f6cf7e26c7 100644 --- a/test/box/access_bin.result +++ b/test/box/access_bin.result @@ -178,3 +178,33 @@ c:close() test:drop() --- ... +-- +-- gh-575: User loses 'universe' grants after alter +-- +box.space._priv:get{1} +--- +- [1, 1, 'universe', 0, 7] +... +u = box.space._user:get{1} +--- +... +box.session.su('admin') +--- +... +box.schema.user.passwd('Gx5!') +--- +... +c = require('net.box').new('admin:Gx5!@'..box.cfg.listen) +--- +... +c:call('dostring', 'return 2 + 2') +--- +- - [4] +... +c:close() +--- +... +box.space._user:replace(u) +--- +- [1, 1, 'admin', 'user'] +... diff --git a/test/box/access_bin.test.lua b/test/box/access_bin.test.lua index f5e95fb7eaedef8578038131e522c5ef2ddf0acd..0dc4162047683da055b6b007dff5a167dcfaa009 100644 --- a/test/box/access_bin.test.lua +++ b/test/box/access_bin.test.lua @@ -67,3 +67,15 @@ c.space.test:insert{1} c:close() test:drop() +-- +-- gh-575: User loses 'universe' grants after alter +-- + +box.space._priv:get{1} +u = box.space._user:get{1} +box.session.su('admin') +box.schema.user.passwd('Gx5!') +c = require('net.box').new('admin:Gx5!@'..box.cfg.listen) +c:call('dostring', 'return 2 + 2') +c:close() +box.space._user:replace(u) diff --git a/test/box/alter.result b/test/box/alter.result index 93d4866c93a82ea89cd8763bfcafe004dc825e16..e5974dc8195617b14807d660197f2cbc2561970e 100644 --- a/test/box/alter.result +++ b/test/box/alter.result @@ -405,3 +405,28 @@ index = s:create_index('primary', {unique = true, parts = 'bug'}) s:drop() --- ... +-- ------------------------------------------------------------------ +-- gh-155 Tarantool failure on simultaneous space:drop() +-- ------------------------------------------------------------------ +--# setopt delimiter ';' +local fiber = require('fiber') +local W = 4 +local N = 50 +local ch = fiber.channel(W) +for i=1,W do + fiber.create(function() + for k=1,N do + local space_id = math.random(2147483647) + local space = box.schema.create_space(string.format('space_%d', space_id)) + space:create_index('pk', { type = 'tree' }) + space:drop() + end + ch:put(true) + end) +end +for i=1,W do + ch:get() +end +--- +... +--# setopt delimiter '' diff --git a/test/box/alter.test.lua b/test/box/alter.test.lua index 3cf6025b2f5b95f5d7c737fc67c1ac1daab42143..d93b775345f51cdc15a1a6d92cb8242473a59da5 100644 --- a/test/box/alter.test.lua +++ b/test/box/alter.test.lua @@ -151,3 +151,29 @@ index = s:create_index('primary', {unique = true, parts = {0, 'NUM', 1, 'STR'}}) index = s:create_index('primary', {unique = true, parts = {'NUM', 1, 'STR', 2}}) index = s:create_index('primary', {unique = true, parts = 'bug'}) s:drop() + + +-- ------------------------------------------------------------------ +-- gh-155 Tarantool failure on simultaneous space:drop() +-- ------------------------------------------------------------------ + +--# setopt delimiter ';' +local fiber = require('fiber') +local W = 4 +local N = 50 +local ch = fiber.channel(W) +for i=1,W do + fiber.create(function() + for k=1,N do + local space_id = math.random(2147483647) + local space = box.schema.create_space(string.format('space_%d', space_id)) + space:create_index('pk', { type = 'tree' }) + space:drop() + end + ch:put(true) + end) +end +for i=1,W do + ch:get() +end +--# setopt delimiter '' diff --git a/test/box/bootstrap.result b/test/box/bootstrap.result new file mode 100644 index 0000000000000000000000000000000000000000..670fab9ff86cb24ef0e53e7f1c082742492de37f --- /dev/null +++ b/test/box/bootstrap.result @@ -0,0 +1,91 @@ +dofile("<builddir>/extra/schema_erase.lua") +--- +... +box.space._schema:select{} +--- +- - ['cluster', '<cluster uuid>'] +... +box.space._cluster:select{} +--- +- - [1, '<server uuid>'] +... +box.space._space:select{} +--- +- [] +... +box.space._index:select{} +--- +- [] +... +box.space._user:select{} +--- +- [] +... +box.space._func:select{} +--- +- [] +... +box.space._priv:select{} +--- +- [] +... +dofile("<builddir>/extra/schema_fill.lua") +--- +... +box.snapshot() +--- +- ok +... +box.space._schema:select{} +--- +- - ['cluster', '<cluster uuid>'] + - ['version', 1, 6] +... +box.space._cluster:select{} +--- +- - [1, '<server uuid>'] +... +box.space._space:select{} +--- +- - [272, 1, '_schema', 'memtx', 0] + - [280, 1, '_space', 'memtx', 0] + - [288, 1, '_index', 'memtx', 0] + - [296, 1, '_func', 'memtx', 0] + - [304, 1, '_user', 'memtx', 0] + - [312, 1, '_priv', 'memtx', 0] + - [320, 1, '_cluster', 'memtx', 0] +... +box.space._index:select{} +--- +- - [272, 0, 'primary', 'tree', 1, 1, 0, 'str'] + - [280, 0, 'primary', 'tree', 1, 1, 0, 'num'] + - [280, 1, 'owner', 'tree', 0, 1, 1, 'num'] + - [280, 2, 'name', 'tree', 1, 1, 2, 'str'] + - [288, 0, 'primary', 'tree', 1, 2, 0, 'num', 1, 'num'] + - [288, 2, 'name', 'tree', 1, 2, 0, 'num', 2, 'str'] + - [296, 0, 'primary', 'tree', 1, 1, 0, 'num'] + - [296, 1, 'owner', 'tree', 0, 1, 1, 'num'] + - [296, 2, 'name', 'tree', 1, 1, 2, 'str'] + - [304, 0, 'primary', 'tree', 1, 1, 0, 'num'] + - [304, 1, 'owner', 'tree', 0, 1, 1, 'num'] + - [304, 2, 'name', 'tree', 1, 1, 2, 'str'] + - [312, 0, 'primary', 'tree', 1, 3, 1, 'num', 2, 'str', 3, 'num'] + - [312, 1, 'owner', 'tree', 0, 1, 0, 'num'] + - [312, 2, 'object', 'tree', 0, 2, 2, 'str', 3, 'num'] + - [320, 0, 'primary', 'tree', 1, 1, 0, 'num'] + - [320, 1, 'uuid', 'tree', 1, 1, 1, 'str'] +... +box.space._user:select{} +--- +- - [0, 1, 'guest', 'user'] + - [1, 1, 'admin', 'user'] + - [2, 1, 'public', 'role'] +... +box.space._func:select{} +--- +- [] +... +box.space._priv:select{} +--- +- - [1, 1, 'universe', 0, 7] +... diff --git a/test/box/bootstrap.test.py b/test/box/bootstrap.test.py new file mode 100644 index 0000000000000000000000000000000000000000..ada352dbf07e64875443de5f4da5dc61434e8969 --- /dev/null +++ b/test/box/bootstrap.test.py @@ -0,0 +1,34 @@ + +import sys +import yaml + +server_uuid = server.get_param('server')['uuid'] +sys.stdout.push_filter(server_uuid, '<server uuid>') +cluster_uuid = yaml.load(server.admin('box.space._schema:get("cluster")', + silent = True))[0][1] +sys.stdout.push_filter(cluster_uuid, '<cluster uuid>') +sys.stdout.push_filter(server.builddir, '<builddir>') + +server.admin('dofile("%s/extra/schema_erase.lua")' % server.builddir) +server.admin('box.space._schema:select{}') +server.admin('box.space._cluster:select{}') +server.admin('box.space._space:select{}') +server.admin('box.space._index:select{}') +server.admin('box.space._user:select{}') +server.admin('box.space._func:select{}') +server.admin('box.space._priv:select{}') + +server.admin('dofile("%s/extra/schema_fill.lua")' % server.builddir) +server.admin("box.snapshot()") +server.restart() + +server.admin('box.space._schema:select{}') +server.admin('box.space._cluster:select{}') +server.admin('box.space._space:select{}') +server.admin('box.space._index:select{}') +server.admin('box.space._user:select{}') +server.admin('box.space._func:select{}') +server.admin('box.space._priv:select{}') + +# Cleanup +sys.stdout.pop_filter() diff --git a/test/box/box.net.box.result b/test/box/box.net.box.result index 58c38375be26804809d6ce1e6d56307612c8f09a..b5af04d8a7ccdcf38bd52825ff6c8794d3a88125 100644 --- a/test/box/box.net.box.result +++ b/test/box/box.net.box.result @@ -634,3 +634,17 @@ cn:ping() cn:close() --- ... +-- #594: bad argument #1 to 'setmetatable' (table expected, got number) +--# setopt delimiter ';' +function gh594() + local cn = remote:new(box.cfg.listen) + local ping = fiber.create(function() cn:ping() end) + cn:call('dostring', 'return 2 + 2') + cn:close() +end; +--- +... +--# setopt delimiter '' +gh594() +--- +... diff --git a/test/box/box.net.box.test.lua b/test/box/box.net.box.test.lua index 9803bc9c5061ea4750a355e8290ebea3385dc06e..65309c0321b16a19598fa61598e31da337251d45 100644 --- a/test/box/box.net.box.test.lua +++ b/test/box/box.net.box.test.lua @@ -252,3 +252,13 @@ cn = remote.new(uri, { password = 'test' }) cn:ping() cn:close() +-- #594: bad argument #1 to 'setmetatable' (table expected, got number) +--# setopt delimiter ';' +function gh594() + local cn = remote:new(box.cfg.listen) + local ping = fiber.create(function() cn:ping() end) + cn:call('dostring', 'return 2 + 2') + cn:close() +end; +--# setopt delimiter '' +gh594() diff --git a/test/box/print.result b/test/box/print.result index 6ab6a18f26467f9ce1003262806b3e46052cac6a..6e0f52976334ecb38169e4d277a0613dd1965a2f 100644 --- a/test/box/print.result +++ b/test/box/print.result @@ -4,17 +4,22 @@ print("Hello, world") io = require('io') --- ... -local f = require('fiber').create(function() print('Ehllo, world') io.flush() end) +local f = require('fiber').create( + function() + print('Ehllo, world') + io.flush() + end +) --- ... require('fiber').sleep(0.1) --- ... -Check log line +Check log line (Hello): --- -- "line contains 'Hello'" +- "logfile contains "Hello"" ... -Check log line +Check log line (Ehllo): --- -- "line contains 'Ehllo'" +- "logfile contains "Ehllo"" ... diff --git a/test/box/print.test.py b/test/box/print.test.py index 5dfdd82e5479b16dabcbd42aeef800d2a68b7382..6f6798fc6191b659d24780552f9e9db29904becf 100644 --- a/test/box/print.test.py +++ b/test/box/print.test.py @@ -4,32 +4,31 @@ import sys import os import re +log = server.get_log() admin('print("Hello, world")') admin("io = require('io')") -log = server.logfile -f = open(log, "r") -f.seek(0, 2) - -admin("local f = require('fiber').create(function() print('Ehllo, world') io.flush() end)") +admin("""local f = require('fiber').create( + function() + print('Ehllo, world') + io.flush() + end +)""") admin("require('fiber').sleep(0.1)") -line = f.readline() -print("Check log line") -print("---") -found = re.search(r'(Hello)', line) -if found and re.search(r'(Hello)', line).start(1) >= 0: - print("""- "line contains 'Hello'" """) - print("...") -else: - print('String "%s" does not contain "Hello"' % line) -line = f.readline() -print("Check log line") -print("---") -if re.search('(Ehllo)', line): - print("""- "line contains 'Ehllo'" """) +print("Check log line (Hello):") +print('---') +if log.seek_once('Hello') >= 0: + print('- "logfile contains "Hello""') else: - print("""- "line doesn't contain 'Ehllo'" """) -print("...") + print('- "logfile does not contain "Hello""') +print('...') +print("Check log line (Ehllo):") +print('---') +if log.seek_once('Ehllo') >= 0: + print('- "logfile contains "Ehllo""') +else: + print('- "logfile does not contain "Ehllo""') +print('...') diff --git a/test/box/xlog.test.py b/test/box/xlog.test.py index 6d70d7491574935c1afb785b51dadd798bc57ad3..82486b3309a9ec26cb1e5dffc78e54d6632465e8 100644 --- a/test/box/xlog.test.py +++ b/test/box/xlog.test.py @@ -89,7 +89,7 @@ lsn += 1 # # wal_inprogress = os.path.join(server.vardir, "00000000000000000006.xlog.inprogress") # wal = os.path.join(server.vardir, "00000000000000000006.xlog") -# +# # os.symlink(abspath("box/empty.xlog"), wal_inprogress) # server.start() # @@ -101,16 +101,16 @@ lsn += 1 # # Empty (header only, no records) inprogress xlog must be deleted # # during recovery. # """ -# +# # # If the previous test has failed, there is a dangling link # # and symlink fails. # try: # os.symlink(abspath("box/just_header.xlog"), wal_inprogress) # except OSError as e: # print e -# +# # server.start() -# +# # if not os.access(wal_inprogress, os.F_OK) and not os.access(wal, os.F_OK): # print "00000000000000000006.xlog.inprogress has been successfully deleted" # server.stop() @@ -118,16 +118,16 @@ lsn += 1 # print """ # # Inprogress xlog with bad record must be deleted during recovery. # """ -# +# # # If the previous test has failed, there is a dangling link # # and symlink fails. # try: # os.symlink(abspath("box/bad_record.xlog"), wal_inprogress) # except OSError as e: # print e -# +# # server.start() -# +# # if not os.access(wal_inprogress, os.F_OK) and not os.access(wal, os.F_OK): # print "00000000000000000006.xlog.inprogress has been successfully deleted" @@ -177,20 +177,13 @@ if os.access(wal, os.F_OK): os.unlink(wal) os.rename(wal_old, wal) -f = open(server.logfile, "r") -f.seek(0, 2) server.start() - -check="Duplicate key" -print "check log line for '%s'" % check +line = 'Duplicate key' +print "check log line for '%s'" % line print -line = f.readline() -while line: - if re.search(r'(%s)' % check, line): - print "'%s' exists in server log" % check - break - line = f.readline() +if server.logfile_pos.seek_once(line) >= 0: + print "'%s' exists in server log" % line print server.admin("box.space['test']:get{1}") @@ -222,16 +215,13 @@ server.stop() # Remove xlog with {3, 'third tuple'} os.unlink(wal) + server.start() -check="ignoring missing WAL" -print "check log line for '%s'" % check +line="ignoring missing WAL" +print "check log line for '%s'" % line print -line = f.readline() -while line: - if re.search(r'(%s)' % check, line): - print "'%s' exists in server log" % check - break - line = f.readline() +if server.logfile_pos.seek_once(line) >= 0: + print "'%s' exists in server log" % line print # missing tuple from removed xlog diff --git a/test/lib/tarantool_server.py b/test/lib/tarantool_server.py index 114f505fbaff71e0aa8b38c274c9c803fa4e4b26..0623e7e8498f2f28ba48dbb63379c62a450efe8d 100644 --- a/test/lib/tarantool_server.py +++ b/test/lib/tarantool_server.py @@ -18,7 +18,6 @@ import subprocess import collections import os.path - try: from cStringIO import StringIO except ImportError: @@ -122,6 +121,21 @@ class TarantoolLog(object): with open(self.path, 'r') as f: f.seek(0, os.SEEK_END) self.log_begin = f.tell() + return self + + def seek_once(self, msg): + if not os.path.exists(self.path): + return -1 + with open(self.path, 'r') as f: + f.seek(self.log_begin, os.SEEK_SET) + while True: + log_str = f.readline() + + if not log_str: + return -1 + pos = log_str.find(msg) + if pos != -1: + return pos def seek_from(self, msg, proc=None): while True: @@ -275,8 +289,7 @@ class TarantoolServer(Server): return self._logfile_pos @logfile_pos.setter def logfile_pos(self, val): - self._logfile_pos = TarantoolLog(val) - self._logfile_pos.positioning() + self._logfile_pos = TarantoolLog(val).positioning() @property def script(self): @@ -613,3 +626,6 @@ class TarantoolServer(Server): version = p.stdout.read().rstrip() p.wait() return version + + def get_log(self): + return TarantoolLog(self.logfile).positioning() diff --git a/test/replication/cluster.test.py b/test/replication/cluster.test.py index d062fcb1f84d60a0c39bd6674aa9a44332a72762..aa41dc0a3010e5390e94d1723becd99020a2c54d 100644 --- a/test/replication/cluster.test.py +++ b/test/replication/cluster.test.py @@ -16,21 +16,14 @@ server.admin("box.info.server.uuid") # Check log message server.stop() -f = open(server.logfile, "r") -f.seek(0, 2) server.start() -check="server uuid changed to " + new_uuid -print "check log line for '%s'" % check +line = "server uuid changed to " + new_uuid +print "check log line for '%s'" % line print -line = f.readline() -while line: - if re.search(r'(%s)' % check, line): - print "'%s' exists in server log" % check - break - line = f.readline() +if server.logfile_pos.seek_once(line) >= 0: + print "'%s' exists in server log" % line print -f.close() server.admin("box.info.server.uuid") # Check that new UUID has been saved in snapshot diff --git a/third_party/sophia b/third_party/sophia index ccabccdd237501f295b234865ebea4d26688368b..44645d81cf4d1bcfc3dad97de23e4e8ecc308265 160000 --- a/third_party/sophia +++ b/third_party/sophia @@ -1 +1 @@ -Subproject commit ccabccdd237501f295b234865ebea4d26688368b +Subproject commit 44645d81cf4d1bcfc3dad97de23e4e8ecc308265