Re: [systemd-devel] race conditions after SIGTERM

2014-07-26 Thread Reindl Harald
and it happended again

how can it be that if i have running mysqld-instances as
Type=simple directly starting mysqld that it is not safe
after systemctl stop returns to rsync the datadirs

i had over a long time in any mysqld-unit
ExecStopPost=/usr/bin/sleep 1
pretty sure because that happened in the past

but that is a really dirty solution
is 1 second enough, if not 2 or better 5
i have now a sleep 6 in the backup scripts - not beautiful

after systemctl stop returns i expect that the MAINPID is
*really* done, has finished it's cleanups and written data
to disk and that systemd especially in case of a non-forking
daemon knows trustable when it is finished

Am 24.07.2014 13:24, schrieb Reindl Harald:
 maybe that's a systemd thing
 
 i know Fedora 19 has not a recent systemd but the question
 remains if systemctl in case of Type=simple may act the same
 way while stop a service as for starting - send the SIGTERM
 and immediately return while the binary still writes data
 
 that could explain race conditions like below
 
 * stop mysqld instance 1
 * stop mysqld instance 2
 * the services still flush data but systemctl already returned
 * rsync both datadir
 * corruption
 
  Original-Nachricht 
 Betreff: race conditions after SIGTERM
 Datum: Thu, 24 Jul 2014 12:42:51 +0200
 Von: Reindl Harald h.rei...@thelounge.net
 An: Mailing-List mariadb maria-discuss@lists.launchpad.net
 
 how can that script lead to a race condition where files
 are not fully written to disk? that never happens if the
 systemd-unit for the replication instance has
 ExecStopPost=/usr/bin/sleep 1 and waits a while
 
 my only explaination is that mysqld returns after the SIGTERM
 from systemd before all data are completly written in some racy
 situations and so rsynced incompletly to the datadir of the
 other instance
 _
 
 #!/bin/bash
 systemctl stop replication.service
 systemctl stop mysqld.service
 rsync $RSYNC_PARAMS /mysql_replication/ /mysql_data/
 systemctl start replication.service
 systemctl start mysqld.service
 _
 
 [Unit]
 Description=MariaDB Replication
 
 [Service]
 Type=simple
 PIDFile=/run/mysqld/mysqld_replication.pid
 ExecStart=/usr/libexec/mysqld --defaults-file=/etc/my-replication.cnf 
 --pid-file=/run/mysqld/mysqld_replication.pid
 --socket=/var/lib/mysql/mysql_replication.sock --open-files-limit=3 
 --basedir=/usr --user=mysql
 Environment=LANG=en_GB.UTF-8
 Restart=always
 RestartSec=1
 _
 
 140724 12:22:59 [Note] /usr/libexec/mysqld: Shutdown complete
 140724 12:23:01 [Note] Plugin 'InnoDB' is disabled.
 Cannot find checkpoint record at LSN (1,0x35767)
 140724 12:23:01 [ERROR] mysqld: Aria recovery failed. Please run aria_chk -r 
 on all Aria tables and delete all
 aria_log. files
 140724 12:23:01 [ERROR] Plugin 'Aria' init function returned error.
 140724 12:23:01 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
 140724 12:23:01 [Note] Plugin 'FEDERATED' is disabled.
 140724 12:23:01 [Note] Plugin 'FEEDBACK' is disabled.
 140724 12:23:01 [ERROR] Aria engine is not enabled or did not start. The Aria 
 engine must be enabled to continue as
 mysqld was configured with --with-aria-tmp-tables
 140724 12:23:01 [ERROR] Aborting
 140724 12:23:01 [Note] /usr/libexec/mysqld: Shutdown complete
 140724 12:23:03 [Note] Plugin 'InnoDB' is disabled.
 Cannot find checkpoint record at LSN (1,0x35767)



signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] shell-completion: prevent mangling unit names

2014-07-26 Thread Eric Cook
Units with literal hex '\xFF' in their names has to be read
and printed properly.
dev-disk-byx2dlabel-root.device != dev-disk-by\x2dlabel-root.device
---
 shell-completion/zsh/_systemctl.in | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/shell-completion/zsh/_systemctl.in 
b/shell-completion/zsh/_systemctl.in
index d364d17..e681ec6 100644
--- a/shell-completion/zsh/_systemctl.in
+++ b/shell-completion/zsh/_systemctl.in
@@ -100,7 +100,7 @@ _systemctl_all_units()
   if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) 
 ! _retrieve_cache SYS_ALL_UNITS;
   then
-_sys_all_units=( $(__systemctl list-units --all | { while read a b; do 
echo  $a; done; }) )
+_sys_all_units=( $(__systemctl list-units --all | { while read -r a b; do 
echo -E -  $a; done; }) )
 _store_cache SYS_ALL_UNITS _sys_all_units
   fi
 }
@@ -113,7 +113,7 @@ _systemctl_really_all_units()
   if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid 
SYS_REALLY_ALL_UNITS ) 
 ! _retrieve_cache SYS_REALLY_ALL_UNITS;
   then
-all_unit_files=( $(__systemctl list-unit-files | { while read a b; do echo 
 $a; done; }) )
+all_unit_files=( $(__systemctl list-unit-files | { while read -r a b; do 
echo -E -  $a; done; }) )
 _systemctl_all_units
 really_all_units=($_sys_all_units $all_unit_files)
 _sys_really_all_units=(${(u)really_all_units})
@@ -138,12 +138,12 @@ _filter_units_by_property() {
   done
 }
 
-_systemctl_active_units()  {_sys_active_units=(  $(__systemctl list-units  
| { while read a b; do echo  $a; done; }) )}
-_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units 
--all| { while read a b c d; do [[ $c == inactive || $c == failed ]]  
echo  $a; done; }) )}
-_systemctl_failed_units()  {_sys_failed_units=(  $(__systemctl list-units 
--failed | { while read a b; do echo  $a; done; }) )}
-_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files 
| { while read a b; do [[ $b == enabled ]]  echo  $a; done; }) )}
-_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files 
| { while read a b; do [[ $b == disabled ]]  echo  $a; done; }) )}
-_systemctl_masked_units()  {_sys_masked_units=(  $(__systemctl list-unit-files 
| { while read a b; do [[ $b == masked ]]  echo  $a; done; }) )}
+_systemctl_active_units()  {_sys_active_units=(  $(__systemctl list-units  
| { while read -r a b; do echo -E -  $a; done; }) )}
+_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units 
--all| { while read -r a b c d; do [[ $c == inactive || $c == failed ]] 
 echo -E -  $a; done; }) )}
+_systemctl_failed_units()  {_sys_failed_units=(  $(__systemctl list-units 
--failed | { while read -r a b; do echo -E -  $a; done; }) )}
+_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files 
| { while read -r a b; do [[ $b == enabled ]]  echo -E -  $a; done; 
}) )}
+_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files 
| { while read -r a b; do [[ $b == disabled ]]  echo -E -  $a; done; 
}) )}
+_systemctl_masked_units()  {_sys_masked_units=(  $(__systemctl list-unit-files 
| { while read -r a b; do [[ $b == masked ]]  echo -E -  $a; done; }) 
)}
 
 # Completion functions for ALL_UNITS
 for fun in is-active is-failed is-enabled status show cat mask preset help 
list-dependencies ; do
@@ -219,8 +219,8 @@ for fun in restart reload-or-restart ; do
   {
 _systemctl_all_units
 compadd $@ - $( _filter_units_by_property CanStart yes \
-  ${_sys_all_units[*]} | while read line; do \
-  [[ $line =~ \.device$ ]] || echo  $line; \
+  ${_sys_all_units[*]} | while read -r line; do \
+  [[ $line =~ \.device$ ]] || echo -E -  $line; \
   done )
   }
 done
-- 
2.0.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] shell-completion: prevent mangling unit names

2014-07-26 Thread Zbigniew Jędrzejewski-Szmek
On Sat, Jul 26, 2014 at 11:15:52AM -0400, Eric Cook wrote:
 Units with literal hex '\xFF' in their names has to be read
 and printed properly.
 dev-disk-byx2dlabel-root.device != dev-disk-by\x2dlabel-root.device
Applied.

Any chance you could do the equivalent for bash?

Zbyszek

 ---
  shell-completion/zsh/_systemctl.in | 20 ++--
  1 file changed, 10 insertions(+), 10 deletions(-)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] always check asprintf return code

2014-07-26 Thread Zbigniew Jędrzejewski-Szmek
On Fri, Jul 25, 2014 at 07:03:20PM +0400, Andrey Borzenkov wrote:
 В Fri, 25 Jul 2014 15:38:31 +0200
 Karel Zak k...@redhat.com пишет:
 
  There is a small number of the places in sources where we don't check
  asprintf() return code and assume that after error the function
  returns NULL pointer via the first argument. That's wrong, after
  error the content of pointer is undefined.
  ---
   src/core/unit-printf.c  |  8 +---
   src/cryptsetup/cryptsetup.c | 11 ---
   src/journal/coredump.c  |  5 ++---
   src/journal/journalctl.c| 16 +++-
   src/run/run.c   | 16 
   src/shared/install.c| 15 +--
   src/systemctl/systemctl.c   | 14 --
   src/tty-ask-password-agent/tty-ask-password-agent.c |  5 +++--
   8 files changed, 54 insertions(+), 36 deletions(-)
  
  diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
  index 5bd30f0..8ac2081 100644
  --- a/src/core/unit-printf.c
  +++ b/src/core/unit-printf.c
  @@ -208,7 +208,9 @@ static int specifier_user_name(char specifier, void 
  *data, void *userdata, char
  @@ -230,8 +232,8 @@ static int specifier_user_name(char specifier, void 
  *data, void *userdata, char
   
   if (specifier == 'u')
   printed = strdup(username);
  -else
  -asprintf(printed, UID_FMT, uid);
  +else (asprintf(printed, UID_FMT, uid)  0)
 
 Missing if?
 
Applied, with the if fixed.

I also applied some other changes, your patch overwrote some state in 
enable_sysv_units().

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] journald: fix syslog facility for messages coming from kmsg

2014-07-26 Thread Zbigniew Jędrzejewski-Szmek
Hm, what was wrong with the facility before?

Zbyszek

On Fri, Jul 25, 2014 at 03:04:44PM +0200, Michal Sekletar wrote:
 ---
  src/journal/journald-kmsg.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
 index 12992e7..8d24344 100644
 --- a/src/journal/journald-kmsg.c
 +++ b/src/journal/journald-kmsg.c
 @@ -274,6 +274,9 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) 
 {
  if (asprintf(syslog_priority, PRIORITY=%i, priority  
 LOG_PRIMASK) = 0)
  IOVEC_SET_STRING(iovec[n++], syslog_priority);
  
 +if (asprintf(syslog_facility, SYSLOG_FACILITY=%i, priority  
 LOG_FACMASK) = 0)
 +IOVEC_SET_STRING(iovec[n++], syslog_facility);
 +
  if ((priority  LOG_FACMASK) == LOG_KERN)
  IOVEC_SET_STRING(iovec[n++], SYSLOG_IDENTIFIER=kernel);
  else {
 @@ -295,9 +298,6 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) 
 {
  if (syslog_pid)
  IOVEC_SET_STRING(iovec[n++], syslog_pid);
  }
 -
 -if (asprintf(syslog_facility, SYSLOG_FACILITY=%i, 
 LOG_FAC(priority)) = 0)
 -IOVEC_SET_STRING(iovec[n++], syslog_facility);
  }
  
  message = cunescape_length_with_prefix(p, pl, MESSAGE=);
 -- 
 2.0.1
 
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] analyze: fix seg-fault with no cl-argument

2014-07-26 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Jul 24, 2014 at 11:29:40PM +0200, Daniel Buch wrote:
 We need to check if argv[1] is set before compare
 ---
  src/analyze/analyze.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
 index 66e2aab..83da7f5 100644
 --- a/src/analyze/analyze.c
 +++ b/src/analyze/analyze.c
 @@ -1349,7 +1349,7 @@ int main(int argc, char *argv[]) {
  if (r = 0)
  goto finish;
  
 -if (streq(argv[optind], verify))
 +if (argv[optind]  streq(argv[optind], verify))
  r = verify_units(argv+optind+1,
   arg_user ? SYSTEMD_USER : SYSTEMD_SYSTEM,
   arg_man);
Applied, with a change to use streq_ptr().

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] shell-completion: prevent mangling unit names (bash)

2014-07-26 Thread Eric Cook
This looks seems like it should work. I would appreciate it if you could trail 
run it.
My use of bash is limited and knowledge of it's completion system even more so.
---
 shell-completion/bash/systemctl.in | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/shell-completion/bash/systemctl.in 
b/shell-completion/bash/systemctl.in
index c5950cc..113694f 100644
--- a/shell-completion/bash/systemctl.in
+++ b/shell-completion/bash/systemctl.in
@@ -46,25 +46,25 @@ __filter_units_by_property () {
 (__systemctl $mode show --property $property -- ${units[@]})
 for ((i=0; $i  ${#units[*]}; i++)); do
 if [[ ${props[i]} = $property=$value ]]; then
-echo  ${units[i]}
+printf '%q\n'  ${units[i]}
 fi
 done
 }
 
 __get_all_units  () { __systemctl $1 list-units --all \
-| { while read -r a b; do echo  $a; done; }; }
+| { while read -r a b; do printf '%q\n'  $a; done; }; }
 __get_active_units   () { __systemctl $1 list-units   \
-| { while read -r a b; do echo  $a; done; }; }
+| { while read -r a b; do printf '%q\n'  $a; done; }; }
 __get_startable_units () { __systemctl $1 list-units --all -t 
service,timer,socket,mount,automount,path,snapshot,swap \
-| { while read -r a b c d; do [[ $c == inactive || $c == failed ]] 
 echo  $a; done; }; }
+| { while read -r a b c d; do [[ $c == inactive || $c == failed ]] 
 printf '%q\n'  $a; done; }; }
 __get_failed_units   () { __systemctl $1 list-units   \
-| { while read -r a b c d; do [[ $c == failed   ]]  echo  $a; 
done; }; }
+| { while read -r a b c d; do [[ $c == failed   ]]  printf '%q\n' 
 $a; done; }; }
 __get_enabled_units  () { __systemctl $1 list-unit-files  \
-| { while read -r a b c  ; do [[ $b == enabled  ]]  echo  $a; 
done; }; }
+| { while read -r a b c  ; do [[ $b == enabled  ]]  printf '%q\n' 
 $a; done; }; }
 __get_disabled_units () { __systemctl $1 list-unit-files  \
-| { while read -r a b c  ; do [[ $b == disabled ]]  echo  $a; 
done; }; }
+| { while read -r a b c  ; do [[ $b == disabled ]]  printf '%q\n' 
 $a; done; }; }
 __get_masked_units   () { __systemctl $1 list-unit-files  \
-| { while read -r a b c  ; do [[ $b == masked   ]]  echo  $a; 
done; }; }
+| { while read -r a b c  ; do [[ $b == masked   ]]  printf '%q\n' 
 $a; done; }; }
 
 _systemctl () {
 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
-- 
2.0.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd-socket-proxyd slapd

2014-07-26 Thread David Timothy Strauss
Would you be willing to post the entire unit files for everything
here, just so future users can see them? Presumably, you're using
JoinsNamespaceOf=proxy-to-directory-400.service in
vgp.master-ldap-400.service?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] shell-completion: prevent mangling unit names (bash)

2014-07-26 Thread Zbigniew Jędrzejewski-Szmek
On Sat, Jul 26, 2014 at 05:24:11PM -0400, Eric Cook wrote:
 This looks seems like it should work. I would appreciate it if you could 
 trail run it.
 My use of bash is limited and knowledge of it's completion system even more 
 so.
 ---

Unfortunately it works only partially. It seems that completions are generated
properly, but bash doesn't seem to be able to continue after a backslash,
so one has to copy in the remaining part by hand.

Zbyszek

  shell-completion/bash/systemctl.in | 16 
  1 file changed, 8 insertions(+), 8 deletions(-)
 
 diff --git a/shell-completion/bash/systemctl.in 
 b/shell-completion/bash/systemctl.in
 index c5950cc..113694f 100644
 --- a/shell-completion/bash/systemctl.in
 +++ b/shell-completion/bash/systemctl.in
 @@ -46,25 +46,25 @@ __filter_units_by_property () {
  (__systemctl $mode show --property $property -- ${units[@]})
  for ((i=0; $i  ${#units[*]}; i++)); do
  if [[ ${props[i]} = $property=$value ]]; then
 -echo  ${units[i]}
 +printf '%q\n'  ${units[i]}
  fi
  done
  }
  
  __get_all_units  () { __systemctl $1 list-units --all \
 -| { while read -r a b; do echo  $a; done; }; }
 +| { while read -r a b; do printf '%q\n'  $a; done; }; }
  __get_active_units   () { __systemctl $1 list-units   \
 -| { while read -r a b; do echo  $a; done; }; }
 +| { while read -r a b; do printf '%q\n'  $a; done; }; }
  __get_startable_units () { __systemctl $1 list-units --all -t 
 service,timer,socket,mount,automount,path,snapshot,swap \
 -| { while read -r a b c d; do [[ $c == inactive || $c == failed 
 ]]  echo  $a; done; }; }
 +| { while read -r a b c d; do [[ $c == inactive || $c == failed 
 ]]  printf '%q\n'  $a; done; }; }
  __get_failed_units   () { __systemctl $1 list-units   \
 -| { while read -r a b c d; do [[ $c == failed   ]]  echo  $a; 
 done; }; }
 +| { while read -r a b c d; do [[ $c == failed   ]]  printf 
 '%q\n'  $a; done; }; }
  __get_enabled_units  () { __systemctl $1 list-unit-files  \
 -| { while read -r a b c  ; do [[ $b == enabled  ]]  echo  $a; 
 done; }; }
 +| { while read -r a b c  ; do [[ $b == enabled  ]]  printf 
 '%q\n'  $a; done; }; }
  __get_disabled_units () { __systemctl $1 list-unit-files  \
 -| { while read -r a b c  ; do [[ $b == disabled ]]  echo  $a; 
 done; }; }
 +| { while read -r a b c  ; do [[ $b == disabled ]]  printf 
 '%q\n'  $a; done; }; }
  __get_masked_units   () { __systemctl $1 list-unit-files  \
 -| { while read -r a b c  ; do [[ $b == masked   ]]  echo  $a; 
 done; }; }
 +| { while read -r a b c  ; do [[ $b == masked   ]]  printf 
 '%q\n'  $a; done; }; }
  
  _systemctl () {
  local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
 -- 
 2.0.2
 
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] shell-completion: prevent mangling unit names (bash)

2014-07-26 Thread Eric Cook
On 07/26/2014 07:52 PM, Zbigniew Jędrzejewski-Szmek wrote:
 Unfortunately it works only partially. It seems that completions are generated
 properly, but bash doesn't seem to be able to continue after a backslash,
 so one has to copy in the remaining part by hand.

 Zbyszek
Hm... (I think)Once we add our own `\' to escape the unit name, the
compgen tests fails to match units. (lines 116, 121 and 225)
That can be avoided in a hack-ish way by escaping `cur' with
`cur=${cur//\\/}' but when completing the unit like 'dev-tab (with
the quote) the additional `\' are still inserted.

So... i'll look more into it, i may be over thinking it. :D
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel