Is it normal that Drupal enters maintenance mode during a module update?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite
1












I have created a custom module with an .install file, which includes some hook_update_N() and hook_update_N(&$sandbox) update hooks.



These are used to update a collection of existing nodes.



Whenever I run drush updb the site automatically enters maintenance mode (anonymous requests get a 503), and if the update is successful, the site goes back online. All by itself.



I couldn't find any resources on the web about this situation. Is it normal? Is there a way to disable this behavior?










share|improve this question





























    up vote
    2
    down vote

    favorite
    1












    I have created a custom module with an .install file, which includes some hook_update_N() and hook_update_N(&$sandbox) update hooks.



    These are used to update a collection of existing nodes.



    Whenever I run drush updb the site automatically enters maintenance mode (anonymous requests get a 503), and if the update is successful, the site goes back online. All by itself.



    I couldn't find any resources on the web about this situation. Is it normal? Is there a way to disable this behavior?










    share|improve this question

























      up vote
      2
      down vote

      favorite
      1









      up vote
      2
      down vote

      favorite
      1






      1





      I have created a custom module with an .install file, which includes some hook_update_N() and hook_update_N(&$sandbox) update hooks.



      These are used to update a collection of existing nodes.



      Whenever I run drush updb the site automatically enters maintenance mode (anonymous requests get a 503), and if the update is successful, the site goes back online. All by itself.



      I couldn't find any resources on the web about this situation. Is it normal? Is there a way to disable this behavior?










      share|improve this question















      I have created a custom module with an .install file, which includes some hook_update_N() and hook_update_N(&$sandbox) update hooks.



      These are used to update a collection of existing nodes.



      Whenever I run drush updb the site automatically enters maintenance mode (anonymous requests get a 503), and if the update is successful, the site goes back online. All by itself.



      I couldn't find any resources on the web about this situation. Is it normal? Is there a way to disable this behavior?







      8 updating batch-api maintenance-mode






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago









      leymannx

      5,66242355




      5,66242355










      asked 2 hours ago









      atwixtor

      1156




      1156




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          It does look to be normal, yes. Drush's UpdateDBCommands::updateBatch, which is responsible for processing the updates, contains this:



          batch_set($batch);

          // See updateFinished() for the restore of maint mode.
          $this->maintenanceModeOriginalState = Drupal::service('state')->get('system.maintenance_mode');
          Drupal::service('state')->set('system.maintenance_mode', true);
          drush_backend_batch_process();


          The code deliberately sets maintenance mode to true before processing the batch, and then restores the original state when it's done.



          Running drush help updb lists the following options:




          • --cache-clear[=CACHE-CLEAR] Clear caches upon completion. [default: "true"]


          • --entity-updates Run automatic entity schema updates at the end of any update hooks.


          • --post-updates[=POST-UPDATES] Run post updates after hook_update_n and entity updates. [default: "true"]


          • --no-cache-clear Negate --cache-clear option.


          • --no-post-updates Negate --post-updates option.

          So there doesn't seem to be an obvious way to disable the behaviour. But if you're updating the database you probably don't want people to be able to access the site at the same time. There's a good explanation for that here.






          share|improve this answer






















          • Thank you. So I suppose if I use update.php instead of drush, I can avoid having the site enter maintenance mode, as it provides you an option there.
            – atwixtor
            2 hours ago






          • 2




            Yes that's the way to get around it, but be sure to read my last edit and Greg's explanation in the linked post as to why that might not be the best idea
            – Clive♦
            2 hours ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "220"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f270793%2fis-it-normal-that-drupal-enters-maintenance-mode-during-a-module-update%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          It does look to be normal, yes. Drush's UpdateDBCommands::updateBatch, which is responsible for processing the updates, contains this:



          batch_set($batch);

          // See updateFinished() for the restore of maint mode.
          $this->maintenanceModeOriginalState = Drupal::service('state')->get('system.maintenance_mode');
          Drupal::service('state')->set('system.maintenance_mode', true);
          drush_backend_batch_process();


          The code deliberately sets maintenance mode to true before processing the batch, and then restores the original state when it's done.



          Running drush help updb lists the following options:




          • --cache-clear[=CACHE-CLEAR] Clear caches upon completion. [default: "true"]


          • --entity-updates Run automatic entity schema updates at the end of any update hooks.


          • --post-updates[=POST-UPDATES] Run post updates after hook_update_n and entity updates. [default: "true"]


          • --no-cache-clear Negate --cache-clear option.


          • --no-post-updates Negate --post-updates option.

          So there doesn't seem to be an obvious way to disable the behaviour. But if you're updating the database you probably don't want people to be able to access the site at the same time. There's a good explanation for that here.






          share|improve this answer






















          • Thank you. So I suppose if I use update.php instead of drush, I can avoid having the site enter maintenance mode, as it provides you an option there.
            – atwixtor
            2 hours ago






          • 2




            Yes that's the way to get around it, but be sure to read my last edit and Greg's explanation in the linked post as to why that might not be the best idea
            – Clive♦
            2 hours ago














          up vote
          3
          down vote



          accepted










          It does look to be normal, yes. Drush's UpdateDBCommands::updateBatch, which is responsible for processing the updates, contains this:



          batch_set($batch);

          // See updateFinished() for the restore of maint mode.
          $this->maintenanceModeOriginalState = Drupal::service('state')->get('system.maintenance_mode');
          Drupal::service('state')->set('system.maintenance_mode', true);
          drush_backend_batch_process();


          The code deliberately sets maintenance mode to true before processing the batch, and then restores the original state when it's done.



          Running drush help updb lists the following options:




          • --cache-clear[=CACHE-CLEAR] Clear caches upon completion. [default: "true"]


          • --entity-updates Run automatic entity schema updates at the end of any update hooks.


          • --post-updates[=POST-UPDATES] Run post updates after hook_update_n and entity updates. [default: "true"]


          • --no-cache-clear Negate --cache-clear option.


          • --no-post-updates Negate --post-updates option.

          So there doesn't seem to be an obvious way to disable the behaviour. But if you're updating the database you probably don't want people to be able to access the site at the same time. There's a good explanation for that here.






          share|improve this answer






















          • Thank you. So I suppose if I use update.php instead of drush, I can avoid having the site enter maintenance mode, as it provides you an option there.
            – atwixtor
            2 hours ago






          • 2




            Yes that's the way to get around it, but be sure to read my last edit and Greg's explanation in the linked post as to why that might not be the best idea
            – Clive♦
            2 hours ago












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          It does look to be normal, yes. Drush's UpdateDBCommands::updateBatch, which is responsible for processing the updates, contains this:



          batch_set($batch);

          // See updateFinished() for the restore of maint mode.
          $this->maintenanceModeOriginalState = Drupal::service('state')->get('system.maintenance_mode');
          Drupal::service('state')->set('system.maintenance_mode', true);
          drush_backend_batch_process();


          The code deliberately sets maintenance mode to true before processing the batch, and then restores the original state when it's done.



          Running drush help updb lists the following options:




          • --cache-clear[=CACHE-CLEAR] Clear caches upon completion. [default: "true"]


          • --entity-updates Run automatic entity schema updates at the end of any update hooks.


          • --post-updates[=POST-UPDATES] Run post updates after hook_update_n and entity updates. [default: "true"]


          • --no-cache-clear Negate --cache-clear option.


          • --no-post-updates Negate --post-updates option.

          So there doesn't seem to be an obvious way to disable the behaviour. But if you're updating the database you probably don't want people to be able to access the site at the same time. There's a good explanation for that here.






          share|improve this answer














          It does look to be normal, yes. Drush's UpdateDBCommands::updateBatch, which is responsible for processing the updates, contains this:



          batch_set($batch);

          // See updateFinished() for the restore of maint mode.
          $this->maintenanceModeOriginalState = Drupal::service('state')->get('system.maintenance_mode');
          Drupal::service('state')->set('system.maintenance_mode', true);
          drush_backend_batch_process();


          The code deliberately sets maintenance mode to true before processing the batch, and then restores the original state when it's done.



          Running drush help updb lists the following options:




          • --cache-clear[=CACHE-CLEAR] Clear caches upon completion. [default: "true"]


          • --entity-updates Run automatic entity schema updates at the end of any update hooks.


          • --post-updates[=POST-UPDATES] Run post updates after hook_update_n and entity updates. [default: "true"]


          • --no-cache-clear Negate --cache-clear option.


          • --no-post-updates Negate --post-updates option.

          So there doesn't seem to be an obvious way to disable the behaviour. But if you're updating the database you probably don't want people to be able to access the site at the same time. There's a good explanation for that here.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 2 hours ago









          Clive♦

          144k13245287




          144k13245287











          • Thank you. So I suppose if I use update.php instead of drush, I can avoid having the site enter maintenance mode, as it provides you an option there.
            – atwixtor
            2 hours ago






          • 2




            Yes that's the way to get around it, but be sure to read my last edit and Greg's explanation in the linked post as to why that might not be the best idea
            – Clive♦
            2 hours ago
















          • Thank you. So I suppose if I use update.php instead of drush, I can avoid having the site enter maintenance mode, as it provides you an option there.
            – atwixtor
            2 hours ago






          • 2




            Yes that's the way to get around it, but be sure to read my last edit and Greg's explanation in the linked post as to why that might not be the best idea
            – Clive♦
            2 hours ago















          Thank you. So I suppose if I use update.php instead of drush, I can avoid having the site enter maintenance mode, as it provides you an option there.
          – atwixtor
          2 hours ago




          Thank you. So I suppose if I use update.php instead of drush, I can avoid having the site enter maintenance mode, as it provides you an option there.
          – atwixtor
          2 hours ago




          2




          2




          Yes that's the way to get around it, but be sure to read my last edit and Greg's explanation in the linked post as to why that might not be the best idea
          – Clive♦
          2 hours ago




          Yes that's the way to get around it, but be sure to read my last edit and Greg's explanation in the linked post as to why that might not be the best idea
          – Clive♦
          2 hours ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f270793%2fis-it-normal-that-drupal-enters-maintenance-mode-during-a-module-update%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          Confectionery