[This is preliminary documentation and subject to change]

# Edit-While-Running Scenario 3

This scenario illustrates how edit-while-running works under the following conditions:

- The MetaBase.XML file is open for edits but not write-locked when the in-memory metabase is written to disk.

What you will learn:

- How edit-while-running handles the situation when the in-memory metabase is written to disk and the MetaBase.XML file is open for edits.

Step 1:
Open MetaBase.XML with a text editor, and change A (A=1) but do not save or close the file. It is recommended that you use Microsoft Notepad to edit the MetaBase.XML file because Notepad does not write-lock files.

Important Changes made using Notepad do not write to the MetaBase.XML file until the changes made in Notepad are saved.

Step 2:
Edit the value of C (C=1) in the in memory metabase, and write the changes to disk.

1. A temporary file is created with the contents of the in-memory metabase.
2. The temporary file is copied to the history folder and renamed by appending the HistoryMajorVersionNumber value to the filename, and the minor version number is reset to zero.
3. The temporary file is copied over MetaBase.XML.
4. The temporary file is deleted.

Step 3:
Save changes made using the text editor, but do not close the text editor.

When the changes are saved, the following happens:

1. The version 5 MetaBase.XML is overwritten with the updated version 4 MetaBase.XML file.
2. The difference between the corresponding history file (MetaBase_0000000004_0000000000.XML) and MetaBase.XML are determined, and the changes are written to the in-memory metabase through the Admin Base Objects.
3. A new history file is created with the contents of the corresponding history file and the changes that were sent to the Admin Base Objects. The minor version number is incremented. Because the HistoryMajorVersionNumber value within the history file is 4, the filename in this case is MetaBase_0000000004_0000000001.XML.

Step 4:
Using Notepad, edit B (B=2) but do not save or close the file.

The application, in this case Microsoft Notepad, is used to edit MetaBase.XML. The MetaBase.XML file is not write-locked by this application, and the values in the MetaBase.XML file do not change until the changes made in Notepad are saved.

Step 5:
Edit the value of A (A=2) and C (C=3) in the in-memory metabase, and write the changes to disk.

1. A temporary file is created with the contents of the in-memory metabase.
2. The temporary file is copied to the history folder and renamed by appending the version number to its name. The version number is incremented, and the minor version number is reset to zero for the file that is moved to the history folder.
3. The temporary file is copied over MetaBase.XML.
4. The temporary file is deleted.

Step 6:
Save the changes made in Notepad (B=2), and close the Notepad application.

1. When the changes made in Notepad are saved, the major version 6 MetaBase.XML file is overwritten with the updated major version 4 MetaBase.XML file.
2. The difference between the corresponding history file and MetaBase.XML are determined, and the changes are written to the in-memory metabase through Admin Base Objects.
3. A new history file is created with the contents of the corresponding history file and the changes that were sent to the Admin Base Objects. The minor version number is incremented. Because the HistoryMajorVersionNumber value within the history file is 4, the filename of the new history file in this case is MetaBase_0000000004_0000000002.XML.

Important The MetaBase.XML file will be out of sync with the in-memory metabase until the in-memory metabase is written to disk, as shown in step 7.

Step 7:
Write the in-memory metabase to disk.

phrase 1, phrase 2, phrase 3

© 1997-2001 Microsoft Corporation. All rights reserved.