*/
public function lastDoneWrites();
+ /**
+ * @return bool Whether there is a transaction open with possible write queries
+ * @since 1.27
+ */
+ public function writesPending();
+
/**
* Returns true if there is a transaction open with possible write
* queries or transaction pre-commit/idle callbacks waiting on it to finish.
public function writesOrCallbacksPending();
/**
- * Get the time spend running write queries for this
+ * Get the time spend running write queries for this transaction
*
* High times could be due to scanning, updates, locking, and such
*
*/
public function pendingWriteQueryDuration();
+ /**
+ * Get the list of method names that did write queries for this transaction
+ *
+ * @return array
+ * @since 1.27
+ */
+ public function pendingWriteCallers();
+
/**
* Is a connection to the database open?
* @return bool
*/
public function endAtomic( $fname = __METHOD__ );
+ /**
+ * Run a callback to do an atomic set of updates for this database
+ *
+ * The $callback takes the following arguments:
+ * - This database object
+ * - The value of $fname
+ *
+ * If any exception occurs in the callback, then rollback() will be called and the error will
+ * be re-thrown. It may also be that the rollback itself fails with an exception before then.
+ * In any case, such errors are expected to terminate the request, without any outside caller
+ * attempting to catch errors and commit anyway. Note that any rollback undoes all prior
+ * atomic section and uncommitted updates, which trashes the current request, requiring an
+ * error to be displayed.
+ *
+ * This can be an alternative to explicit startAtomic()/endAtomic() calls.
+ *
+ * @see DatabaseBase::startAtomic
+ * @see DatabaseBase::endAtomic
+ *
+ * @param string $fname Caller name (usually __METHOD__)
+ * @param callable $callback Callback that issues DB updates
+ * @throws DBError
+ * @throws RuntimeException
+ * @throws UnexpectedValueException
+ * @since 1.27
+ */
+ public function doAtomicSection( $fname, $callback );
+
/**
* Begin a transaction. If a transaction is already in progress,
* that transaction will be committed before the new transaction is started.
* installations. Most callers should use LoadBalancer::safeGetLag()
* instead.
*
- * @return int Database replication lag in seconds
+ * @return int|bool Database replication lag in seconds or false on error
*/
public function getLag();
* safe to be pessimistic. In AUTO-COMMIT mode, this still gives an
* indication of the staleness of subsequent reads.
*
- * @return array ('lag': seconds, 'since': UNIX timestamp of BEGIN)
+ * @return array ('lag': seconds or false on error, 'since': UNIX timestamp of BEGIN)
* @since 1.27
*/
public function getSessionLagStatus();