Question
· Aug 7, 2017

Recreate cache.dat file to increase space on disk

Hi,

I use cache 5.0 and access cache through OpenVMS.

The disk-space under a particular namespace has grown up in size due to cache.dat. How to recreate cache.dat to bring up more space back on disk?

Discussion (11)1
Log in or sign up to continue

definitely a good idea to run routine ^%GSIZE  to find the big consumers and packing

directory: c:\intersystems\cache\mgr\user\
Page: 1                           GLOBAL SIZE                        08 Aug 2017
                                                                        10:28 AM
      Global        Blocks       Bytes Used  Packing   Contig.
      --------    --------  ---------------  -------   -------
      CacheStd           1              140      2 %         0
      CacheStdS          1               92      1 %         0
      CacheStream      109          764.376     86 %        70
      ERRORS             1               12      0 %         0
      G1                 1               72      1 %         0

Doc for 5.0 is available at http://docs.intersystems.com/documentation/cache/cache5docs/

At the bottom of that page I found this:

Using the Caché GBLOCKCOPY Routine —  This article describes the basics of running GBLOCKCOPY to copy globals.

The link is to a PDF. One of the use cases in the PDF is as follows:

Reclaim unused space in a database
If a large global is created then killed in a database, there may be a large excess of unused space in the database. This space can be removed by copying all the globals in the database to a new one, and then replacing the old database with the new database.

That's what I think you need to do. It sounds like you used GBLOCKCOPY to copy to a namespace in an existing database rather than to a fresh empty database.

Of course, you will need enough disk space to have the smaller new database alongside the big database until you have completed the copying.

It's a very long time since I used GBLOCKCOPY on a Cache 5.0 system, but I think you may be able to simplify your steps.

1. Create a new temporary database via Configuration Manager. You probably don't need a new namespace as well.

2. Use GBLOCKCOPY to copy your old database contents into your new database.

3. Dismount your old database and your new one. Or just shut down Cache completely.

4. Rename your old database (the big one), e.g. to CACHE.oldDAT

5. Move the temporary database's CACHE.DAT file to where the old one was.

6. Mount your database (or start Cache).

7. Use Configuration Manager to delete the temporary database you defined in step 1.

8 Check everything is working.

9. Delete the renamed big database file you preserved in step 4.

10. Come back to DC, tell us how it went, and set the checkmark against one of the answers to show you have accepted it.

Thanks. Pleas let me know if the following work plan is correct...

  1. Create a new temporary namespace and database using Configuration Manager.
  2. Do ^GBLOCKCOPY from %SYS namespace to copy all the globals to the newly created temporary database
  3. DELETE cache.dat
  4. Create new cache.dat file
  5. Again do a ^GBLOCKCOPY to copy all globals from newly created temporary database to the old one
  6. Delete the newly created namespace and database.

Also would a direct DELETE cache.dat work?

It's not yet time for GBLOCKCOPY.
In namespace %SYS you should find a routine ^GCOMPACT
(at least according to docs http://docs.intersystems.com/documentation/cache/cache5docs/PDFS/GMSM.pdf)

Based on the results of %GSIZE you now compact those globals with most blocks and lowest packing.
This generates free blocks that will be eliminated during GBLOCKCOPY.

Routine ^%FREECNT might help you to follow up your efforts
Purpose: Displays the total amount of disk space within a volume group and the amount of free space.

HTH

Why do you think that it may help you? Do you know how much data in your database?

As 5.0 is so old I even not remember how to check the actual size of data in the Database. But I think you can do the integrity check, and in this report, you will have this information in last rows.

And then if you will have less than 10-20% of free space, I think it will not be needed for you. And with this report, you can see how big all globals in this database, and if some useless globals may be unexpectedly exists or have unexpected size. If so, you should check your code, why it could happen and remove it, so you can increase free space, which can be used then for grown useful globals.

If you will have so much free space, which you want to free, you can use ^GBLOCKCOPY, to copy all or only useful globals to the new database.