Skip to content

Commit

Permalink
Quota: Update comment on Commit()/ScheduledCommit()
Browse files Browse the repository at this point in the history
Address comments in https://crrev.com/c/3574803

Updates comments on the Commit()/ScheduledCommit()
for bucket creation & deletion and the implication
of these choices. As well as a TODO for a detailed
plan on handling inconsistencies between the db and
the file system directory.

Bug: 1312955
Change-Id: Idfadf54a7a8789b60fa69847bd6d6b035874b605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3577286
Reviewed-by: Austin Sullivan <asully@chromium.org>
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Cr-Commit-Position: refs/heads/main@{#990663}
  • Loading branch information
ayuishii authored and Chromium LUCI CQ committed Apr 8, 2022
1 parent f767cae commit b92c3c9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions storage/browser/quota/quota_database.cc
Expand Up @@ -561,11 +561,15 @@ QuotaError QuotaDatabase::DeleteBucketInfo(BucketId bucket_id) {

// Scheduling this commit introduces the chance of inconsistencies
// between the buckets table and data stored on disk in the file system.
// If there is a crash, or a battery failure before the transaction is
// If there is a crash or a battery failure before the transaction is
// committed, the bucket directory may be deleted from the file system,
// while an entry still may exist in the database.
//
// TODO(crbug.com/1314129): Update to immediately commit transaction.
// While this is not ideal, this does not introduce any new edge case.
// We should check that bucket IDs have existing associated directories,
// because database corruption could result in invalid bucket IDs.
// TODO(crbug.com/1314567): For handling inconsistencies between the db and
// the file system.
ScheduleCommit();

return QuotaError::kNone;
Expand Down Expand Up @@ -1039,9 +1043,9 @@ QuotaErrorOr<BucketInfo> QuotaDatabase::CreateBucketInternal(
int64_t bucket_id = db_->GetLastInsertRowId();
DCHECK_GT(bucket_id, 0);

// Commit so bucket data is persisted immediately. This reduces the chance of
// inconsistencies between the buckets table and data stored on disk in the
// filesystem.
// Commit immediately so that we persist the bucket metadata to disk before we
// inform other services / web apps (via the Buckets API) that we did so.
// Once informed, that promise should persist across power failures.
Commit();

return BucketInfo(BucketId(bucket_id), storage_key, type, bucket_name,
Expand Down

0 comments on commit b92c3c9

Please sign in to comment.