Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Each object instance is named as "objectId#currentTimeMillis<objectId>#<currentTimeMillis>" in the tape. The naming is not really important. The name should contain the objectId, so reindexing of the tapes are possible. To help people reading the tapes with normal tar tools, the names should be unique (inside the tape, if not globally), as extracting the content becomes annoying otherwise. This system, however, would not mind.

The tapes themselves are named "tape#<currentTimeMillis>.tar"

When an outputstream is opened to a blob, the global write lock is acquired by this thread. As Fedora does not tell the blob how much data it is going to write, the outputstream will buffer the written data until the stream is closed. When the stream is closed, the buffer will be written to the newest tape as a new tar entry. The object instance will be registered in the index. Lastly, the write lock will be released. 

...

Upon startup, the server goes through the following process.

  1. It lists and sorts by name all the tapes in the given tape folder. The tapes should therefore be named in a fashion that allows the system to sort by name to get a last-modified sorting.
  2. For each tape it checks if the index marks this tape as indexed.
  3. If the tape is not indexed, it is read through for indexing.
  4. Any further tapes in the list are also indexed the same way.

As mentioned, a tape is only marked as indexed when closed, so the newest tape will always be indexed upon server startup. 

Indexing a tape

...

Indexing a tape

The tape is read through from the beginning. This process is fast, as we can skip over the actual record contents. The relevant information here are the objectIds, the tape name and the offset of the record. For each tar record, the index is updated in the same way as it would have been when the record was written.This update will overwrite any entry that already existed in the index. As the tapes are read in order of creation-time (this is encoded in the tape name) and the records in the tape are written in order, when all entries concerning a given objectId have been indexed, the index can be sure to have the information about the newest instance of the record. 

When a tape have been indexed, it is marked as such in the index.

The newest tape will be indexed, but will not be marked as indexed here, even through it is not closed. Should this change?

Broken tapes

Sometimes the tapes can become broken (not observed yet). This is detected only during startup, when the tape is read for indexing. This means that if a tape have already been indexed, it will not be verified upon startup. most likely something to happen when the server terminates abnormally, and leave a tape with half a record. Upon startup, if the property "fixErrors" is set, the newest tape and only the newest tape is read through to check for this. Any tape but the newest tape should not be able to contain broken records, barring a general failure of the underlying filesystem, so they are not checked.

If an IOException occurs while reading the he tape, the system regards the tape as broken and attempts to fix it. The fix is rather brutal. Every record, from the beginning of the tape, is read and written to a new temp tape, until the broken tape either runs out of bytes or the IOException reoccurs. This is done in a way to ensure that the temp tape will only have complete records. When no more can be read from the broken tape, it is deleted and replaced with the temp tape. The indexing then proceeds to the next tape in the listand replaced with the temp tape.

Rebuild

If the archive is set to rebuild, it will flush (as in flush the toilet) the content of the redis database upon startup. This will mean that no tape will be listed as indexed, so the entire tape archive will be reindexed. The redis client have some harsh requirements about timeouts on commands, and at times the flush will not return in time. In that case the server will fail to start. Simply restarting the server afterwards is the cure, as the redis instance should be finished flushing by then.

Purged objects

The tapes do support purging objects. When a blob is deleted, it is written as a new instance of 0 bytes to the tape. The name of the record is now "objectId#timestampInMillis#DELETED". When an object is deleted, it is removed from the index. Upon indexing the tape (see above), records of 0 bytes with names ending in "#DELETED" cause the objectId to be removed from the index.

...