Hhvm php.ini misconfiguration, broken sessions


#1

Hello,

There is a misconfiguration of hhvm in php.ini, resulting in broken sessions.

Error description: Session path is incorrect, resulting in sessions being inaccessible by hhvm. Error reported: Unknown error type: [2] open(/var/lib/php5/sess_83782d707123eec95839b8d9ab37b1e7, O_RDWR) failed: Permission denied (13) Unknown error type: [2] No such file or directory

How to fix the error: Open file /var/hhvm/php.ini On line 3: Remove: session.save_path = /var/lib/php5/ Replace with: session.save_path = /var/lib/php5/sessions

Please correct this in the rtcamp repository, so ee stack update will not be affected in the future anymore.


#2

Hello @klemen,

In EasyEngine we are not changing default session.save_path value for HHVM.

Also I just now checked on fresh Ubuntu 14.04 x64 system.

root@vagrant-ubuntu-trusty-64:~# cat /etc/hhvm/php.ini 
; php options
session.save_handler = files
session.save_path = /var/lib/hhvm/sessions

Can you give me few more details so that I can debug more:

lsb_release -a
hhvm --version

#3

Hello, here is the information requested.

root@dl:/etc/nginx/common# ee update
Downloading update script        [Done]
updating EasyEngine, please wait...
Executing apt-get update, please wait...
[ Mon Jul  6 17:34:44 CEST 2015 ] You already have EasyEngine 3.2.2, exit status =  1
root@dl:/etc/nginx/common# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04 LTS
Release:	14.04
Codename:	trusty
root@dl:/etc/nginx/common# hhvm --version
HipHop VM 3.7.0 (rel)
Compiler: tags/HHVM-3.7.0-0-gc8baf9cd3cb603e030969bfe24634d5e85549915
Repo schema: 1988ce75e6a571ce9c79c60fd7dc3ca8a5a5d403
root@dl:/etc/nginx/common#

#4

i have the same error too… tried the solution stated klemen, but no luck…

    Warning in ./libraries/session.inc.php#101
 session_start(): open(/var/run/php5/sessions/sess_6pgip10mcttmhpdba75pjk4hp52r24k0, O_RDWR) failed: No such file or directory (2)

Backtrace

./libraries/session.inc.php#101: session_start()
./libraries/common.inc.php#349: require(./libraries/session.inc.php)
./index.php#12: require_once(./libraries/common.inc.php)

well there’s no /var/run/php5/sessions to begin with

after i saw the file >> /etc/hhvm/php.ini it is stated >>> session.save_path = /var/lib/hhvm/sessions

so i just change it to /var/run/php5/sessions


i’m trying to make the sessions stored in the new /var/run/php5/sessions folder… so that it will work smoothly… i hope this is the right move…

i’ll update later…

i’m running on ubuntu

:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:        14.04
Codename:       trusty

:~$ hhvm --version
HipHop VM 3.9.1 (rel)
Compiler: tags/HHVM-3.9.1-0-g0f72cfc2f0a01fdfeb72fbcfeb247b72998a66db
Repo schema: 6416960c150a4a4726fda74b659105ded8819d9c

thank you!

update:

this is what i do to solve this >> change the /etc/hhvm/php.ini adjust the session.save_path to right one (in my case, /var/run/php5/sessions (see my error log))

save and restart…

make dir for /var/run/php5/sessions

and chown the folder to www-data


and the error disappear… i hope this is the right solution for creating sessions, so that there’s no new error arising from it…

hope this helps!


#5

Problem with saving sessions in /var/lib/hhvm/sessions is that they are not purged and you can get inode errors.

Change to config like this in /etc/hhvm/php.ini

session.save_handler = files
session.save_path = /var/lib/php5/sessions
session.gc_probability = 0
session.gc_maxlifetime = 1440

Then the crontab (/etc/cron.d/php5) to purge the files will operate correctly.

See also HHVM session files


#6

Further update to this. I realised that even by changing sessions to …/php5 as above that it was still not clearing sessions via the cron.

I had to change sessions path to session.save_path = /var/lib/php/sessions in /etc/hhvm/php.ini :

; php options
session.save_handler = files
; session.save_path = /var/lib/hhvm/sessions
; session.save_path = /var/lib/php5/sessions
session.save_path = /var/lib/php/sessions
session.gc_probability = 0
session.gc_maxlifetime = 1440

; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false

And then also manually edit the session clean script (/usr/lib/php5/sessionclean) as follows and hardcode the options:

#!/bin/sh -e

SAPIS="apache2:apache2\napache2filter:apache2\ncgi:php5\nfpm:php5-fpm\n"

# Iterate through all web SAPIs
(
proc_names=""
printf "$SAPIS" | \
while IFS=: read -r conf_dir proc_name; do
    if [ -e /etc/php5/cli/php.ini ]; then
        # Get all session variables once so we don't need to start PHP to get each config option
        session_config=$(/usr/bin/php -c /etc/php5/cli/php.ini -d "error_reporting='~E_ALL'" -r 'foreach(ini_get_all("session") as $k => $v) echo "$k=".$v["local_value"]."\n";')
        save_handler=files
        save_path=/var/lib/php/sessions
        gc_maxlifetime=1440
        if [ "$save_handler" = "files" -a -d "$save_path" ]; then
            proc_names="$proc_names $proc_name";
            printf "%s:%s\n" "$save_path" "$gc_maxlifetime"
        fi
    fi
done
# first find all open session files and touch them (hope it's not massive amount of files)
for pid in $(pidof $proc_names); do
    find "/proc/$pid/fd" -ignore_readdir_race -lname "$save_path/sess_\*" -exec touch -c {} \;
done
) | sort -rn -t: -k2,2 | sort -u -t: -k 1,1 | while IFS=: read -r save_path gc_maxlifetime; do
    # find all files older then maxlifetime and delete them
    find -O3 "$save_path" -depth -mindepth 1 -name 'sess_*' -ignore_readdir_race -type f -cmin "+$gc_maxlifetime" -delete
done

exit 0

After that, the cron is working properly and no more running out of inodes!


#7