Create System Log record, when stale semaphore is discovered or hit

Components

Labels

Description

  1. when somebody hits a semaphore and sees error message log it into "System Log" with "Error" Log Level - 0.5h

  2. add following columns to "Semaphores" table: - 0.5h

    • MainIDs - db type: text; comma-separated list of IDs

    • UserId - db type: int

    • IpAddress - db type: varchar(15)

    • Hostname - db type: varchar(255)

    • LogRequestURI - db type: varchar(255)

    • Backtrace - db type: longtext;

  3. add following setting in the "System Settings" sub-section in the "Configuration > Website > Advanced" section: - 0.5h

    • name: "SemaphoreLifetime"

    • title: "Semaphore Inactivity Timeout (seconds)"

    • default: 300 (means 5 minutes)

  4. create "adm:OnDeleteStaleSemaphores" event, that will: - 1.5h

    • get records from "Semaphores" table, where "Semaphores.Timestamp + {SemaphoreLifetime} > UNIX_TIMESTAMP()"

    • if none found, then exit

    • for each found record:

      • create record in "SystemLog" table (using "$this->Application->log" method) where:

        • the "setLogField" method will be used to replace "LogHostname", "LogRequestSource", "LogRequestURI", "LogUserId", "IpAddress" and "LogSessionKey" field values with one, that Semaphore has

        • the "addTrace" method will be used to add trace from semaphore

        • the "setUserData" method will be used to store: value of "MainIDs" field, semaphore creation time, semaphore removal time

        • "Log Level" would be "error"

        • "Message" would be "Stale semaphore discovered"

        • goal is to make that record look like it was created along with semaphore creation

      • delete semaphore record

    • turn "adm:OnDeleteStaleSemaphores" event into a scheduled task, that will run each 5 minutes - 0.5h

Quote: 3.5h*1.4=5h

Context Information

None

Additional information (do not use)

None

Activity

[API] Administrator November 21, 2023 at 9:06 AM

User committed a fix to 5.2.x. Commit Message:

Fixes https://in-portal.atlassian.net/browse/INP-1569#icft=INP-1569 - Create System Log record, when stale semaphore is discovered or hit

Differential Revision: http://qa.in-portal.org/D440

Alex February 3, 2023 at 5:00 PM

Test plan missing.

Fixed

Details

Priority

Assignee

Reporter

Developer

Reviewer

Change Log Group

Added

Change Log Message

Patch Instructions

Patches must be submitted through Phabricator.

Time tracking

4h 53m logged

Story Points

Fix versions

Created June 27, 2016 at 9:22 AM
Updated December 29, 2024 at 8:47 PM
Resolved November 21, 2023 at 9:06 AM

Flag notifications