InnoDB: will uncommitted transaction produce redo log?












1















Before MySQL commit a transaction, it will write REDO log first, then commit the transaction, that is write ahead log.



start transaction;

update users set uuid = UUID() from user where id = 1
update users set uuid = UUID() from user where id = 2
update users set uuid = UUID() from user where id = 3
...
...
update users set uuid = UUID() from user where id = 1,000,000
// not yet commit


If a transaction is going to update 1 million records, which takes 100 seconds. During the period of execution, will this uncommitted transaction produce redo log?










share|improve this question

























  • What index(es) are there?

    – Rick James
    Dec 27 '18 at 16:04
















1















Before MySQL commit a transaction, it will write REDO log first, then commit the transaction, that is write ahead log.



start transaction;

update users set uuid = UUID() from user where id = 1
update users set uuid = UUID() from user where id = 2
update users set uuid = UUID() from user where id = 3
...
...
update users set uuid = UUID() from user where id = 1,000,000
// not yet commit


If a transaction is going to update 1 million records, which takes 100 seconds. During the period of execution, will this uncommitted transaction produce redo log?










share|improve this question

























  • What index(es) are there?

    – Rick James
    Dec 27 '18 at 16:04














1












1








1


1






Before MySQL commit a transaction, it will write REDO log first, then commit the transaction, that is write ahead log.



start transaction;

update users set uuid = UUID() from user where id = 1
update users set uuid = UUID() from user where id = 2
update users set uuid = UUID() from user where id = 3
...
...
update users set uuid = UUID() from user where id = 1,000,000
// not yet commit


If a transaction is going to update 1 million records, which takes 100 seconds. During the period of execution, will this uncommitted transaction produce redo log?










share|improve this question
















Before MySQL commit a transaction, it will write REDO log first, then commit the transaction, that is write ahead log.



start transaction;

update users set uuid = UUID() from user where id = 1
update users set uuid = UUID() from user where id = 2
update users set uuid = UUID() from user where id = 3
...
...
update users set uuid = UUID() from user where id = 1,000,000
// not yet commit


If a transaction is going to update 1 million records, which takes 100 seconds. During the period of execution, will this uncommitted transaction produce redo log?







mysql innodb transaction-log recovery






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 21 '18 at 6:48







Ryan Lv

















asked Dec 21 '18 at 6:09









Ryan LvRyan Lv

6318




6318













  • What index(es) are there?

    – Rick James
    Dec 27 '18 at 16:04



















  • What index(es) are there?

    – Rick James
    Dec 27 '18 at 16:04

















What index(es) are there?

– Rick James
Dec 27 '18 at 16:04





What index(es) are there?

– Rick James
Dec 27 '18 at 16:04










3 Answers
3






active

oldest

votes


















1














innodb produce redo log during transaction and may sync to disk even if the transaction has not committed.






share|improve this answer



















  • 1





    Could you please provide the documentation or reference?

    – Ryan Lv
    Dec 21 '18 at 6:51



















0














The log_buffer is a finite size. When it overflows, stuff will be written to the logfile. Regardless of the value of innodb_flatc, the transaction will eventually be flushed to disk.






share|improve this answer
























  • Hi Rick, thanks for you reply. I updated my question to make it more clean.

    – Ryan Lv
    Dec 21 '18 at 6:42



















0














Based on Jeremy Cole's presentation InnoDB: A journey to the core III in Percona Live MySQL Conference 2015.



When the transaction is first started:




  1. A transaction ID (TRX_ID) is assigned and may be written to the highest transaction ID field in the TRX_SYS page. A record of the TRX_SYS page modification is redo logged if the field

  2. A read view is created based on the assigned TRX_ID.


Record modification



Each time the UPDATE modifies a record:




  1. Undo log space is allocated.

  2. Previous values from record are copied to undo log.

  3. Record of undo log modifications are written to redo log.

  4. Page is modified in buffer pool; rollback pointer is pointed to
    previous version written in undo log.

  5. Record of page modifications are written to redo log.

  6. Page is marked as “dirty” (needs to be flushed to disk).
    Therefore the answer is yes.


Transaction commit



When the transaction is committed (implicitly or explicitly):




  1. Undo log page state is set to “purge” (meaning it can be cleaned up when it’s no longer needed).

  2. Record of undo log modifications are written to redo log.

  3. Redo log buffer is flushed to disk (depending on the setting of
    innodb_flush_log_at_trx_commit).


Conclusion



Will uncommitted transaction produce redo log?



Yes.



Reference




  1. https://www.percona.com/live/mysql-conference-2015

  2. https://docplayer.net/62963586-Innodb-a-journey-to-the-core-ii-jeremy-cole-and-davi-arnaut.html





share























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "182"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f225532%2finnodb-will-uncommitted-transaction-produce-redo-log%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    innodb produce redo log during transaction and may sync to disk even if the transaction has not committed.






    share|improve this answer



















    • 1





      Could you please provide the documentation or reference?

      – Ryan Lv
      Dec 21 '18 at 6:51
















    1














    innodb produce redo log during transaction and may sync to disk even if the transaction has not committed.






    share|improve this answer



















    • 1





      Could you please provide the documentation or reference?

      – Ryan Lv
      Dec 21 '18 at 6:51














    1












    1








    1







    innodb produce redo log during transaction and may sync to disk even if the transaction has not committed.






    share|improve this answer













    innodb produce redo log during transaction and may sync to disk even if the transaction has not committed.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 21 '18 at 6:13









    depeng jidepeng ji

    111




    111








    • 1





      Could you please provide the documentation or reference?

      – Ryan Lv
      Dec 21 '18 at 6:51














    • 1





      Could you please provide the documentation or reference?

      – Ryan Lv
      Dec 21 '18 at 6:51








    1




    1





    Could you please provide the documentation or reference?

    – Ryan Lv
    Dec 21 '18 at 6:51





    Could you please provide the documentation or reference?

    – Ryan Lv
    Dec 21 '18 at 6:51













    0














    The log_buffer is a finite size. When it overflows, stuff will be written to the logfile. Regardless of the value of innodb_flatc, the transaction will eventually be flushed to disk.






    share|improve this answer
























    • Hi Rick, thanks for you reply. I updated my question to make it more clean.

      – Ryan Lv
      Dec 21 '18 at 6:42
















    0














    The log_buffer is a finite size. When it overflows, stuff will be written to the logfile. Regardless of the value of innodb_flatc, the transaction will eventually be flushed to disk.






    share|improve this answer
























    • Hi Rick, thanks for you reply. I updated my question to make it more clean.

      – Ryan Lv
      Dec 21 '18 at 6:42














    0












    0








    0







    The log_buffer is a finite size. When it overflows, stuff will be written to the logfile. Regardless of the value of innodb_flatc, the transaction will eventually be flushed to disk.






    share|improve this answer













    The log_buffer is a finite size. When it overflows, stuff will be written to the logfile. Regardless of the value of innodb_flatc, the transaction will eventually be flushed to disk.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 21 '18 at 6:14









    Rick JamesRick James

    41.7k22258




    41.7k22258













    • Hi Rick, thanks for you reply. I updated my question to make it more clean.

      – Ryan Lv
      Dec 21 '18 at 6:42



















    • Hi Rick, thanks for you reply. I updated my question to make it more clean.

      – Ryan Lv
      Dec 21 '18 at 6:42

















    Hi Rick, thanks for you reply. I updated my question to make it more clean.

    – Ryan Lv
    Dec 21 '18 at 6:42





    Hi Rick, thanks for you reply. I updated my question to make it more clean.

    – Ryan Lv
    Dec 21 '18 at 6:42











    0














    Based on Jeremy Cole's presentation InnoDB: A journey to the core III in Percona Live MySQL Conference 2015.



    When the transaction is first started:




    1. A transaction ID (TRX_ID) is assigned and may be written to the highest transaction ID field in the TRX_SYS page. A record of the TRX_SYS page modification is redo logged if the field

    2. A read view is created based on the assigned TRX_ID.


    Record modification



    Each time the UPDATE modifies a record:




    1. Undo log space is allocated.

    2. Previous values from record are copied to undo log.

    3. Record of undo log modifications are written to redo log.

    4. Page is modified in buffer pool; rollback pointer is pointed to
      previous version written in undo log.

    5. Record of page modifications are written to redo log.

    6. Page is marked as “dirty” (needs to be flushed to disk).
      Therefore the answer is yes.


    Transaction commit



    When the transaction is committed (implicitly or explicitly):




    1. Undo log page state is set to “purge” (meaning it can be cleaned up when it’s no longer needed).

    2. Record of undo log modifications are written to redo log.

    3. Redo log buffer is flushed to disk (depending on the setting of
      innodb_flush_log_at_trx_commit).


    Conclusion



    Will uncommitted transaction produce redo log?



    Yes.



    Reference




    1. https://www.percona.com/live/mysql-conference-2015

    2. https://docplayer.net/62963586-Innodb-a-journey-to-the-core-ii-jeremy-cole-and-davi-arnaut.html





    share




























      0














      Based on Jeremy Cole's presentation InnoDB: A journey to the core III in Percona Live MySQL Conference 2015.



      When the transaction is first started:




      1. A transaction ID (TRX_ID) is assigned and may be written to the highest transaction ID field in the TRX_SYS page. A record of the TRX_SYS page modification is redo logged if the field

      2. A read view is created based on the assigned TRX_ID.


      Record modification



      Each time the UPDATE modifies a record:




      1. Undo log space is allocated.

      2. Previous values from record are copied to undo log.

      3. Record of undo log modifications are written to redo log.

      4. Page is modified in buffer pool; rollback pointer is pointed to
        previous version written in undo log.

      5. Record of page modifications are written to redo log.

      6. Page is marked as “dirty” (needs to be flushed to disk).
        Therefore the answer is yes.


      Transaction commit



      When the transaction is committed (implicitly or explicitly):




      1. Undo log page state is set to “purge” (meaning it can be cleaned up when it’s no longer needed).

      2. Record of undo log modifications are written to redo log.

      3. Redo log buffer is flushed to disk (depending on the setting of
        innodb_flush_log_at_trx_commit).


      Conclusion



      Will uncommitted transaction produce redo log?



      Yes.



      Reference




      1. https://www.percona.com/live/mysql-conference-2015

      2. https://docplayer.net/62963586-Innodb-a-journey-to-the-core-ii-jeremy-cole-and-davi-arnaut.html





      share


























        0












        0








        0







        Based on Jeremy Cole's presentation InnoDB: A journey to the core III in Percona Live MySQL Conference 2015.



        When the transaction is first started:




        1. A transaction ID (TRX_ID) is assigned and may be written to the highest transaction ID field in the TRX_SYS page. A record of the TRX_SYS page modification is redo logged if the field

        2. A read view is created based on the assigned TRX_ID.


        Record modification



        Each time the UPDATE modifies a record:




        1. Undo log space is allocated.

        2. Previous values from record are copied to undo log.

        3. Record of undo log modifications are written to redo log.

        4. Page is modified in buffer pool; rollback pointer is pointed to
          previous version written in undo log.

        5. Record of page modifications are written to redo log.

        6. Page is marked as “dirty” (needs to be flushed to disk).
          Therefore the answer is yes.


        Transaction commit



        When the transaction is committed (implicitly or explicitly):




        1. Undo log page state is set to “purge” (meaning it can be cleaned up when it’s no longer needed).

        2. Record of undo log modifications are written to redo log.

        3. Redo log buffer is flushed to disk (depending on the setting of
          innodb_flush_log_at_trx_commit).


        Conclusion



        Will uncommitted transaction produce redo log?



        Yes.



        Reference




        1. https://www.percona.com/live/mysql-conference-2015

        2. https://docplayer.net/62963586-Innodb-a-journey-to-the-core-ii-jeremy-cole-and-davi-arnaut.html





        share













        Based on Jeremy Cole's presentation InnoDB: A journey to the core III in Percona Live MySQL Conference 2015.



        When the transaction is first started:




        1. A transaction ID (TRX_ID) is assigned and may be written to the highest transaction ID field in the TRX_SYS page. A record of the TRX_SYS page modification is redo logged if the field

        2. A read view is created based on the assigned TRX_ID.


        Record modification



        Each time the UPDATE modifies a record:




        1. Undo log space is allocated.

        2. Previous values from record are copied to undo log.

        3. Record of undo log modifications are written to redo log.

        4. Page is modified in buffer pool; rollback pointer is pointed to
          previous version written in undo log.

        5. Record of page modifications are written to redo log.

        6. Page is marked as “dirty” (needs to be flushed to disk).
          Therefore the answer is yes.


        Transaction commit



        When the transaction is committed (implicitly or explicitly):




        1. Undo log page state is set to “purge” (meaning it can be cleaned up when it’s no longer needed).

        2. Record of undo log modifications are written to redo log.

        3. Redo log buffer is flushed to disk (depending on the setting of
          innodb_flush_log_at_trx_commit).


        Conclusion



        Will uncommitted transaction produce redo log?



        Yes.



        Reference




        1. https://www.percona.com/live/mysql-conference-2015

        2. https://docplayer.net/62963586-Innodb-a-journey-to-the-core-ii-jeremy-cole-and-davi-arnaut.html






        share











        share


        share










        answered 8 mins ago









        Ryan LvRyan Lv

        6318




        6318






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Database Administrators Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f225532%2finnodb-will-uncommitted-transaction-produce-redo-log%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            الفوسفات في المغرب

            Four equal circles intersect: What is the area of the small shaded portion and its height

            بطل الاتحاد السوفيتي