grep -i ./glossary

Glossary of this post

17 terms from the post “Two locks that do not know each other: why a PHP request waits when the server is free”. Every term has a permanent address, and you can pin terms for review and export them.

Back to the post

  1. Session

    Information the server keeps about a visitor from one request to the next

    Full explanation PHP keeps a small file on the server for every visitor, and the browser holds only its identifier, in a cookie. The function session_start() opens the file and locks it until the script ends, so all the requests of the same visitor run one after the other. In SQL Server the same word means a connection to the database, and the two have nothing to do with each other.

    Why remember it The lock is on it, so the queue belongs to one visitor

    #php-session
  2. Session Lock

    The lock PHP puts on the session until the script ends

    Full explanation The lock is taken inside session_start() and released at the end of the script, or when session_write_close() is called. Another request from the same browser waits inside its own session_start(), before its code starts. The lock is on the whole session, not on one key inside it.

    Why remember it The first lock: the database does not see it

    Where it appears in the post

    #session-lock
  3. File Lock

    A lock the operating system puts on a file

    Why remember it That is how a session stored in files is locked

    Where it appears in the post

    #file-lock
  4. Session Handler

    The component that determines where the session is stored: files, Redis or a database

    Full explanation PHP's default is storage in files (session.save_handler = files), and there every session is locked with a file lock. With other storage the locking depends on the handler: in the phpredis extension, for example, locking is off by default and has to be turned on in the settings.

    Why remember it The locking depends on it and on its settings

    Where it appears in the post

    #session-handler
  5. session_write_close()

    A function that saves the session and releases the lock

    Full explanation After the call the $_SESSION array stays in memory and reading from it works as usual, but writing to it is not saved, and PHP does not warn about it. To write again you call session_start() again, before output is sent to the browser; the call loads the data from storage and overwrites what was written to the array while it was closed.

    Why remember it One line that stops holding up the other requests

    #session-write-close
  6. Private Window

    A browser window that starts without the cookies of the regular window

    Why remember it The fastest check: it has a session of its own

    #private-window
  7. Transaction

    A group of changes in the database that is carried out entirely or cancelled entirely

    Full explanation A transaction is closed with COMMIT, which saves the changes, or with ROLLBACK, which cancels them. The lock on a changed row belongs to the transaction and not to the request that opened it: as long as the transaction is open, the row is locked.

    Why remember it The rows it changes are locked until it ends

    #db-transaction
  8. Blocking

    A request waiting for a lock that another request holds

    Why remember it The second lock: the database knows who is blocking whom

    Where it appears in the post

    #db-blocking
  9. Isolation Level

    The setting that determines what one transaction sees of another one's changes

    Full explanation In SQL Server the default is READ COMMITTED. When the READ_COMMITTED_SNAPSHOT setting is off, which is the default there, a read waits for a row that another transaction changed and has not closed yet. In Azure SQL Database the setting is on by default, and such a read does not wait.

    Why remember it Because of it, even a `SELECT` can wait for a locked row

    Where it appears in the post

    #isolation-level
  10. sys.dm_exec_requests

    A SQL Server system view that shows the requests running right now

    Full explanation For every waiting request, the column blocking_session_id holds the number of the connection that blocks it, wait_type the type of the wait, and wait_time the length of the wait in milliseconds. The word session here means a connection to the database, not a PHP session.

    Why remember it In it you see who is waiting, for whom, and for how long

    #dm-exec-requests

Glossary term

Why remember it

Where it appears in the post

    Open in the glossary

    Saved in this browser only

    My pinned terms

    No pinned terms yet. You can pin a term from its explanation, or from the glossary page.

      Pinned terms on the glossary page

      Search and commands