Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Does snapshot happen atomically at a SINGLE point in time?

  1. #11

    Default Re: Does snapshot happen atomically at a SINGLE point in time?

    Quote Originally Posted by arvidjaar View Post
    That said, there is no serialization with other processes doing IO which means of process A writes to file and process B creates snapshot at the same time it is undefined whether changes made by process A will be part of snapshot.
    That is exactly answer to the question I was asking and I'll leave it at that! Thank you!

  2. #12
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,916
    Blog Entries
    2

    Default Re: Does snapshot happen atomically at a SINGLE point in time?

    Originally Posted by arvidjaar
    That said, there is no serialization with other processes doing IO which means of process A writes to file and process B creates snapshot at the same time it is undefined whether changes made by process A will be part of snapshot.



    That is exactly answer to the question I was asking and I'll leave it at that! Thank you!

    ****************************

    Actually, the problem is not if a process has written or not at the time the snapshot is taken...

    An example of the actual problem is if you were to modify the data in multiple linked tables in a database, the database would have to make changes in each and every linked table for the data's integrity to be preserved.
    Take for instance if you deposit money in your bank account.
    The process of depositing money might require multiple steps, removing money from one account and placing in another account, and each step might further need to go through additional steps like authentication and authorization, ensuring that the proposed transaction won't violate banking rules, and more.
    You want the entire transaction to succeed ensuring the money is verified in your account, if the transaction was interrupted you don't want to walk away believing your money was deposited if the transaction didn't complete because if you know the transaction failed, you'd want to cancel the failed transaction and try again. From the bank's perspective it wouldn't want money withdrawn from an account and then never deposited in its destination, resulting in the electronic funds in some state of unaccountable limbo.

    The above is a rough example of what an atomic transaction is supposed to accomplish, verifying the completion of the transaction which ensures the integrity of the data... so you can't have half-transactions that corrupt the data.

    Note that because part of the data is written while some not, at the "write data" level the write functions have each completed successfully, it's the more complex idea that multiple writes comprise a greater collection of data that must itself have transactional integrity.
    In the above money deposit example, you wouldn't want to have the transaction fully completed until every step has been completed and both the deposited and withdrawn funds verified in their respective accounts.

    A BTRFS snapshot unaware of an example like what was described is like cutting the power as soon as funds had been withdrawn but not yet deposited or vice versa. If any part of the transaction was uncompleted, then you'd have "successful writes" ie parts of the transaction completed successfully but other parts not and whatever cut the power wouldn't have any way to be aware what was completed or not. In the same way, a BTRFS snapshot won't have any idea what might be happening in a database application at the moment the snapshot is taken... All the snapshot knows is that writes have completed but not know if more writes are needed to preserve data integrity.

    HTH,
    TSU




    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #13
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    885

    Default Re: Does snapshot happen atomically at a SINGLE point in time?

    Quote Originally Posted by tsu2 View Post
    Unfortunately,
    You actually describe the most common scenario that is actually broken by snapshotting...
    When you're talking about a database and database transactions, you can have long running transactions (sequential flow, very large data changes), and since a snapshot is completely unaware of these kinds of operations cannot guarantee data integrity.

    This is why snapshots should expressly never be enabled where there is a database unless some day the BTRFS snapshot is made "application aware."
    So, for example in the MSWindows world,there is a snapshot technology called "Volume Shadow Copy" -- Where plugins are written to make it aware of specific database and mail applications, so that the application (and activity) is issued a suspend command and when the suspend happens only then the snapshot is created.

    BTRFS snapshots have no such "application awareness" so will create snapshots immediately regardless of application state and if data is in flight it's anyone's guess what will be in your snapshot.

    So yes... although there is no such thing as an atomic snapshot (go ahead and look that up, you won't find anything except a fairly specialized situation that has nothing to do with what we're talking about here), there definitely is such a thing as an "atomic transaction."

    BTW -
    Disregard anything anyone has to say about bitrot... It's FUD.
    I've spoken to disk manufacturers directly who do extensive testing on their own products, and they say that as long as you care for your disk there is no such thing as bitrot.

    TSU
    Fortunately I am only quoting a bold claim from the above linked article. I don't buy that claim and therefore posted it for comment. Btrfs snapshots are not atomic in a strict sense, but they represent exactly the condition it was in at a given instant in time. I perfectly agree regarding application awareness.

    Bitrot indeed occured with some HDDs, e.g. 100 sectors flagged as "198 Offline_Uncorrectable" by smartctl on a ST380020. No more failed sectors since a decade!
    AMD Athlon 4850e (2009), openSUSE 13.1, KDE 4, Intel i3-4130 (2014), i7-6700K (2016), i5-8250U (2018), openSUSE Tumbleweed, KDE Plasma 5

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •