Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON output options for fdbbackup status and describe #1248

Merged
merged 17 commits into from Mar 14, 2019

Conversation

satherton
Copy link
Contributor

@satherton satherton commented Mar 6, 2019

This adds a --json option for fdbbackup status and fdbbackup describe. The main thing to review here is the JSON structure, as once tooling begins to rely on it it becomes unpleasant to change.

Describe example:

{
    "ContiguousLogEnd": {
        "EpochSeconds": 1551883929,
        "Timestamp": "2019/03/06.06:52:09-0800",
        "Version": 16063194305
    },
    "ExpiredEnd": {
        "EpochSeconds": 1551873029,
        "Timestamp": "2019/03/06.03:50:29-0800",
        "Version": 5163194305
    },
    "MaxLogEnd": {
        "EpochSeconds": 1551883929,
        "Timestamp": "2019/03/06.06:52:09-0800",
        "Version": 16063194305
    },
    "MaxRestorablePoint": {
        "EpochSeconds": 1551883929,
        "Timestamp": "2019/03/06.06:52:09-0800",
        "Version": 16063194304
    },
    "MinLogBegin": {
        "EpochSeconds": 1551873029,
        "Timestamp": "2019/03/06.03:50:29-0800",
        "Version": 5163194305
    },
    "MinRestorablePoint": {
        "EpochSeconds": 1551873269,
        "Timestamp": "2019/03/06.03:54:29-0800",
        "Version": 5403580719
    },
    "Restorable": true,
    "Snapshots": [
        {
            "End": {
                "EpochSeconds": 1551873170,
                "Timestamp": "2019/03/06.03:52:50-0800",
                "Version": 5303412258
            },
            "PercentageExpired": 52.9187,
            "Restorable": false,
            "Start": {
                "EpochSeconds": 1551872873,
                "Timestamp": "2019/03/06.03:47:53-0800",
                "Version": 5005591280
            },
            "TotalBytes": 534079704
        },
        {
            "End": {
                "EpochSeconds": 1551873269,
                "Timestamp": "2019/03/06.03:54:29-0800",
                "Version": 5403580719
            },
            "PercentageExpired": 0,
            "Restorable": true,
            "Start": {
                "EpochSeconds": 1551873171,
                "Timestamp": "2019/03/06.03:52:51-0800",
                "Version": 5304541180
            },
            "TotalBytes": 534079704
        },
        {
            "End": {
                "EpochSeconds": 1551873369,
                "Timestamp": "2019/03/06.03:56:09-0800",
                "Version": 5503301259
            },
            "PercentageExpired": 0,
            "Restorable": true,
            "Start": {
                "EpochSeconds": 1551873273,
                "Timestamp": "2019/03/06.03:54:33-0800",
                "Version": 5406630150
            },
            "TotalBytes": 534079704
        }
    ],
    "TotalSnapshotBytes": 1602239112,
    "URL": "file:///backup1/backup-2019-03-05-16-51-00.648306",
    "UnreliableEnd": {
        "EpochSeconds": 1551873029,
        "Timestamp": "2019/03/06.03:50:29-0800",
        "Version": 5163194305
    }
}
{
    "ContiguousLogEnd": {
        "RelativeDays": 0,
        "Version": 38702087768248
    },
    "ExpiredEnd": {
        "RelativeDays": -28.1847,
        "Version": 36266931416547
    },
    "MaxLogEnd": {
        "RelativeDays": 0,
        "Version": 38702087768248
    },
    "MaxRestorablePoint": {
        "RelativeDays": -1.15741e-11,
        "Version": 38702087768247
    },
    "MinLogBegin": {
        "RelativeDays": -28.1847,
        "Version": 36266931416547
    },
    "MinRestorablePoint": {
        "RelativeDays": -13.1426,
        "Version": 37566566597431
    },
    "Restorable": true,
    "Snapshots": [
        {
            "End": {
                "RelativeDays": -23.1431,
                "Version": 36702520588301
            },
            "PercentageExpired": 49.5861,
            "Restorable": false,
            "Start": {
                "RelativeDays": -33.1434,
                "Version": 35838494704336
            },
            "TotalBytes": 18700188384953
        },
        {
            "End": {
                "RelativeDays": -13.1426,
                "Version": 37566566597431
            },
            "PercentageExpired": 0,
            "Restorable": true,
            "Start": {
                "RelativeDays": -23.1428,
                "Version": 36702549025905
            },
            "TotalBytes": 19328872989291
        },
        {
            "End": {
                "RelativeDays": -3.14202,
                "Version": 38430617368697
            },
            "PercentageExpired": 0,
            "Restorable": true,
            "Start": {
                "RelativeDays": -13.1422,
                "Version": 37566601599290
            },
            "TotalBytes": 20006834842423
        }
    ],
    "TotalSnapshotBytes": 58035896216667,
    "URL": "blobstore://...",
    "UnreliableEnd": {
        "RelativeDays": -28.1847,
        "Version": 36266931416547
    }

Status examples:

{
    "BackupAgentsPaused": false,
    "DestinationURL": "file:///backup1/backup-2019-03-07-01-06-23.829880",
    "Errors": [],
    "LatestRestorablePoint": {
        "EpochSeconds": 1551926207,
        "Timestamp": "2019/03/06.18:36:47-0800",
        "Version": 58341232251
    },
    "Restorable": true,
    "Status": {
        "Completed": true,
        "Description": "has been completed",
        "Name": "Completed",
        "Running": false
    },
    "Tag": "default"
}
{
    "BackupAgentsPaused": false,
    "CurrentSnapshot": {
        "Begin": {
            "EpochSeconds": 1552154654,
            "Timestamp": "2019/03/09.10:04:14-0800",
            "Version": 286787920029
        },
        "EndTarget": {
            "EpochSeconds": 1552154754,
            "Timestamp": "2019/03/09.10:05:54-0800",
            "Version": 286887920029
        },
        "ExpectedProgress": 1.18738,
        "IntervalSeconds": 100,
        "LastDispatch": {
            "EpochSeconds": 1552154654,
            "ShardsBehind": 1,
            "Timestamp": "2019/03/09.10:04:14-0800",
            "Version": 286788021126
        }
    },
    "DestinationURL": "file:///backup-2019-03-11-12-11-10.345342",
    "Errors": [],
    "LatestLogEnd": {
        "EpochSeconds": 1552154652,
        "Timestamp": "2019/03/09.10:04:12-0800",
        "Version": 286785319411
    },
    "LatestSnapshotEnd": {
        "EpochSeconds": 1552154654,
        "Timestamp": "2019/03/09.10:04:14-0800",
        "Version": 286787728144
    },
    "LogBytesWritten": 0,
    "RangeBytesWritten": 182292662,
    "Restorable": false,
    "SnapshotIntervalSeconds": 100,
    "Status": {
        "Completed": false,
        "Description": "has been started",
        "Name": "Running",
        "Running": true
    },
    "StopAfterSnapshot": false,
    "Tag": "default"
}

@satherton satherton added this to the 6.1 milestone Mar 6, 2019
@@ -4127,7 +4130,7 @@ class FileBackupAgentImpl {
Reference<IBackupContainer> bc = wait(backupConfig.backupContainer().getOrThrow(cx));

TraceEvent("AS_StartRestore");
Version ver = wait( restore(backupAgent, cx, tagName, KeyRef(bc->getURL()), ranges, true, -1, true, addPrefix, removePrefix, true, randomUid) );
Version ver = wait( restore(backupAgent, cx, cx, tagName, KeyRef(bc->getURL()), ranges, true, -1, true, addPrefix, removePrefix, true, randomUid) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant ... cx, cxOrig, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, atomicRestore() is a backup/restore test that uses a single database which is both the source of a backup and the destination for a restore of that backup. It takes a single database handle with a running backup, locks the database, completes the backup, restores the backup, then unlocks the database.

…. Added epochs field to JSON objects describing versions and timestamps in backup status and describe output, renamed some fields for clarity.
@satherton satherton requested a review from brownleej March 7, 2019 19:21
…nged Epochs to EpochSeconds in backup JSON along with some other renaming/moving of fields, and added information about snapshot dispatch. Changed timestamp format for input/output in all backup/restore contexts to be a fully qualified time with timezone offset. Added information about the last snapshot dispatch to backup config and status (not yet populated).
…r so status can determine if a snapshot is lagging the configured speed.
…de by zero if the snapshot scheduled interval is 0.
KeyBackedProperty<Version> snapshotDispatchLastVersion() {
return configSpace.pack(LiteralStringRef(__FUNCTION__));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two new properties are not being read in this PR. I see that they are cleared in one place but i could not spot any reads of these properties. Am i missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is read in FileBackupAgent.actor.cpp, which is where the JSON status is generated. You probably just need to click "load diff" on that file, it's large enough that GitHub hides it by default.

Copy link
Contributor

@bnamasivayam bnamasivayam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion if you haven't already considered about it. How about having a version for the JSON schema? This might help making any breaking changes to the schema less painful.

…ckup status JSON, the document was being created outside the transaction retry loop so retries would combine partial element sets across all tries into the result.
@satherton
Copy link
Contributor Author

Added schema versions, and along the way noticed and fixed a bug.


loop {
try {
state JsonBuilderObject doc;
doc.setKey("SchemaVersion", "1.0.0");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define a constant 'SchemaVersion' instead of using "1.0.0." in multiple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two document formats are independent, one is for description of data in a backup and the other is status about running backups. They will evolve independently.

@bnamasivayam bnamasivayam merged commit 2ac07fe into apple:master Mar 14, 2019
etschannen pushed a commit to etschannen/foundationdb that referenced this pull request Mar 26, 2019
JSON output options for fdbbackup status and describe
etschannen pushed a commit to etschannen/foundationdb that referenced this pull request Mar 26, 2019
JSON output options for fdbbackup status and describe
alexmiller-apple pushed a commit to etschannen/foundationdb that referenced this pull request Mar 26, 2019
JSON output options for fdbbackup status and describe
@satherton satherton deleted the feature-backup-json branch November 13, 2019 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants