Forums | Mahara Community

Support /
Disk usage calculation is very slow with NFS


Yaju Mahida's profile picture
Posts: 131

25 February 2020, 12:33

We experienced a very strange issue while upgrading from Mahara 18.10.3 to 19.10.1. It was stuck at cron_site_data_daily() in the htdocs\lib\db\upgrade.php, taking forever to calculate disk usage and failing the upgrade process after 10 minutes. It was opening the database transaction and waiting forever for dirsize function to finish.

    if ($oldversion < 2019011500) {

        log_debug('run cron_site_data_daily function to update data with new chartjs structure');

        cron_site_data_daily();

    }

The cron job call the same function and it is stuck for a very long time due to the same reasons.

We believe this is an NFS file locking issue. The data root is mounted on an NFS volume,  and it is around 500 GB. Even the Linux du utility takes around 20 minutes to calculate the size of this NFS mount point.

 

We fixed this issue by swapping the dirsize function (htdocs\lib\function.dirsize.php) with a custom function which utilizes disk_total_space and disk_free_space.

 

function usqdirsize($path) {

    $disktotalspace = disk_total_space($path);

    $diskfreespace = disk_free_space($path);

    $diskusage = $disktotalspace - $diskfreespace;

 

    return $diskusage;

}

Question: do we need to calculate the size of a directory by iterating its contents? If not happy to commit this patch with a bug report.

Robert Lyon's profile picture
Posts: 757

25 February 2020, 13:15

Hi Yaju,

Please make a patch - the current code is from 2010 so there is bound to better / easier ways to work out the disk usage now

Cheers

Robert

2 results