[GRASS-git] [OSGeo/grass] 8b3b00: init: Use VACUUM for large, modified SQLite files ...

Vaclav Petras noreply at github.com
Wed Jul 27 06:56:43 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 8b3b000c96cda5be6d06f67e7f32d5b7a6b1ecc7
      https://github.com/OSGeo/grass/commit/8b3b000c96cda5be6d06f67e7f32d5b7a6b1ecc7
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M lib/init/grass.py
    M python/grass/script/setup.py

  Log Message:
  -----------
  init: Use VACUUM for large, modified SQLite files only (#2377)

For SQLite database, VACUUM is used when the session is ending. There is a cost in running the task even when the database is small and no vacuuming is needed. This change adds a check for the size of the database and ignores databases under MEMORYMB value or 300MB.

Use MEMORYMB as info for what small file means. If user does not have a problem keeping 300MB or more in memory, there is likely enough space on the disk for many files of that size. If database cleanup is needed, user can always run VACUUM manually or configure SQLite to do automatic vacuums.

Additionally, vacuum runs only if the database was modified since the start of the session because there is no need to vacuum when it is only read or unused. Any edits, including additions, still trigger the vacuum.

Unlike the original implementation, the vacuum task is now synchronous so that there is no running GRASS process after the session has ended. The original code runs relatively quickly, because it just starts the vacuum subprocess which then runs on its own. However, this dangling subprocess may cause unexpected behavior (locked SQLite, process termination on shared hardware). The new code waits for the process to finish, but vacuums only for large, modified database files.

The message is now only verbose and printed in parallel while the task is running.

The original implementation comes from Trac ticket 3697 (https://trac.osgeo.org/grass/ticket/3697) and is best visible in a bulk backport commit f790d68470cf8c3eba0de8feb2d6937c4f9c7493 (https://trac.osgeo.org/grass/changeset/73736).




More information about the grass-commit mailing list