code: public function useMaster(callable $callback)
      {
          if ($this->enableSlaves) {
              $this->enableSlaves = false;
              try {
                  $result = call_user_func($callback, $this);
              } catch (\Exception $e) {
                  $this->enableSlaves = true;
                  throw $e;
              } catch (\Throwable $e) {
                  $this->enableSlaves = true;
                  throw $e;
              }
              // TODO: use "finally" keyword when miminum required PHP version is >= 5.5
              $this->enableSlaves = true;
          } else {
              $result = call_user_func($callback, $this);
          }
  
          return $result;
      }
docs: Executes the provided callback by using the master connection.
  
  This method is provided so that you can temporarily force using the master connection to perform
  DB operations even if they are read queries. For example,
  
  ```php
  $result = $db->useMaster(function ($db) {
  return $db->createCommand('SELECT * FROM user LIMIT 1')->queryOne();
  });
  ```
  
  @param callable $callback a PHP callable to be executed by this method. Its signature is
  `function (Connection $db)`. Its return value will be returned by this method.
  @return mixed the return value of the callback
  @throws \Exception|\Throwable if there is any exception thrown from the callback