Page MenuHomePhabricator

Can neither load the session nor create an empty session
Closed, ResolvedPublic

Description

Trending in fatalmonitor since 1.27.0-wmf.11 hit the test wikis today.

{
  "_index": "logstash-2016.01.20",
  "_type": "mediawiki",
  "_id": "AVJclfvzlAIL90Zztzzb",
  "_score": null,
  "_source": {
    "message": "Can neither load the session nor create an empty session",
    "@version": 1,
    "@timestamp": "2016-01-20T01:11:19.000Z",
    "type": "mediawiki",
    "host": "mw1218",
    "level": "ERROR",
    "tags": [
      "syslog",
      "es",
      "es",
      "exception-json",
      "normalized_message_untrimmed"
    ],
    "channel": "exception",
    "url": "/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400",
    "ip": "xxx.xxx.xxx.xxx",
    "http_method": "GET",
    "server": "www.mediawiki.org",
    "referrer": "https://es.wikipedia.org/wiki/Nuevas_siete_maravillas_del_mundo_moderno",
    "uid": "097c74e",
    "process_id": 29748,
    "wiki": "mediawikiwiki",
    "private": true,
    "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php",
    "line": 232,
    "code": 0,
    "backtrace": [
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/PHPSessionHandler.php",
        "line": 239,
        "function": "getSessionById",
        "class": "MediaWiki\\Session\\SessionManager",
        "type": "->",
        "args": [
          "string"
        ]
      },
      {
        "function": "write",
        "class": "MediaWiki\\Session\\PHPSessionHandler",
        "type": "->",
        "args": [
          "string",
          "string"
        ]
      },
      {
        "function": "call_user_func",
        "args": [
          "array",
          "string",
          "string"
        ]
      },
      {
        "function": "write",
        "class": "__SystemLib\\SessionForwardingHandler",
        "type": "->",
        "args": [
          "string",
          "string"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php",
        "line": 592,
        "function": "session_write_close",
        "args": []
      },
      {
        "function": "shutdown",
        "class": "MediaWiki\\Session\\SessionManager",
        "type": "->",
        "args": []
      }
    ],
    "previous": {
      "id": "8da7669b",
      "type": "InvalidArgumentException",
      "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php",
      "line": 257,
      "message": "Session ID already exists",
      "code": 0,
      "url": "/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400",
      "backtrace": [
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php",
          "line": 223,
          "function": "getEmptySessionInternal",
          "class": "MediaWiki\\Session\\SessionManager",
          "type": "->",
          "args": [
            "FauxRequest",
            "string"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/PHPSessionHandler.php",
          "line": 239,
          "function": "getSessionById",
          "class": "MediaWiki\\Session\\SessionManager",
          "type": "->",
          "args": [
            "string"
          ]
        },
        {
          "function": "write",
          "class": "MediaWiki\\Session\\PHPSessionHandler",
          "type": "->",
          "args": [
            "string",
            "string"
          ]
        },
        {
          "function": "call_user_func",
          "args": [
            "array",
            "string",
            "string"
          ]
        },
        {
          "function": "write",
          "class": "__SystemLib\\SessionForwardingHandler",
          "type": "->",
          "args": [
            "string",
            "string"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php",
          "line": 592,
          "function": "session_write_close",
          "args": []
        },
        {
          "function": "shutdown",
          "class": "MediaWiki\\Session\\SessionManager",
          "type": "->",
          "args": []
        }
      ]
    },
    "exception_id": "d39bb4a2",
    "class": "mediawiki",
    "message_checksum": "e9ca78920ae33253dffd58a42c18f46e",
    "normalized_message": "Can neither load the session nor create an empty session"
  },
  "sort": [
    1453252279000
  ]
}

All of them seem to have Session ID already exists as the previous Exception which sounds like a race condition in the new session storage layer.

Event Timeline

bd808 created this task.Jan 20 2016, 1:20 AM
bd808 raised the priority of this task from to Needs Triage.
bd808 updated the task description. (Show Details)
bd808 added subscribers: bd808, Anomie, Tgr.
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald TranscriptJan 20 2016, 1:20 AM
 {
  "function": "shutdown",
  "class": "MediaWiki\\Session\\SessionManager",
  "type": "->",
  "args": []
}

Do they all start with that?

Tgr added a comment.Jan 20 2016, 3:35 AM

My ES-fu is too weak to get a list of distinct URLs but just by eyeballing it seems to be limited to action=raw (JS pages) and Special:CentralAutoLogin/start.

Tgr added a comment.Jan 20 2016, 3:46 AM

That was the autologin one. The JS one is

{
  "_index": "logstash-2016.01.20",
  "_type": "mediawiki",
  "_id": "AVJdIW1LlAIL90ZzwbOp",
  "_score": null,
  "_source": {
    "message": "Can neither load the session nor create an empty session",
    "@version": 1,
    "@timestamp": "2016-01-20T03:43:36.000Z",
    "type": "mediawiki",
    "host": "mw1021",
    "level": "ERROR",
    "tags": [
      "syslog",
      "es",
      "es",
      "exception-json",
      "normalized_message_untrimmed"
    ],
    "channel": "exception",
    "url": "/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=raw&ctype=text/javascript",
    "ip": "10.64.32.104",
    "http_method": "GET",
    "server": "www.mediawiki.org",
    "referrer": "https://en.wikipedia.org/wiki/Scottish_Journal_of_Political_Economy",
    "uid": "72cee3f",
    "process_id": 10011,
    "wiki": "mediawikiwiki",
    "private": true,
    "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php",
    "line": 232,
    "code": 0,
    "backtrace": [
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/WebRequest.php",
        "line": 658,
        "function": "getSessionById",
        "class": "MediaWiki\\Session\\SessionManager",
        "type": "->",
        "args": [
          "string",
          "boolean",
          "WebRequest"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php",
        "line": 1149,
        "function": "getSession",
        "class": "WebRequest",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php",
        "line": 359,
        "function": "loadFromSession",
        "class": "User",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php",
        "line": 5020,
        "function": "load",
        "class": "User",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php",
        "line": 2606,
        "function": "loadOptions",
        "class": "User",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/context/RequestContext.php",
        "line": 368,
        "function": "getOption",
        "class": "User",
        "type": "->",
        "args": [
          "string"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/Message.php",
        "line": 648,
        "function": "getLanguage",
        "class": "RequestContext",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/context/RequestContext.php",
        "line": 462,
        "function": "setContext",
        "class": "Message",
        "type": "->",
        "args": [
          "RequestContext"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/context/ContextSource.php",
        "line": 186,
        "function": "msg",
        "class": "RequestContext",
        "type": "->",
        "args": [
          "string"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/OutputPage.php",
        "line": 1000,
        "function": "msg",
        "class": "ContextSource",
        "type": "->",
        "args": [
          "string"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/actions/Action.php",
        "line": 355,
        "function": "setPageTitle",
        "class": "OutputPage",
        "type": "->",
        "args": [
          "string"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/actions/FormlessAction.php",
        "line": 38,
        "function": "setHeaders",
        "class": "Action",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php",
        "line": 494,
        "function": "show",
        "class": "FormlessAction",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php",
        "line": 286,
        "function": "performAction",
        "class": "MediaWiki",
        "type": "->",
        "args": [
          "Article",
          "Title"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php",
        "line": 738,
        "function": "performRequest",
        "class": "MediaWiki",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php",
        "line": 510,
        "function": "main",
        "class": "MediaWiki",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.11/index.php",
        "line": 43,
        "function": "run",
        "class": "MediaWiki",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/w/index.php",
        "line": 3,
        "function": "include",
        "args": [
          "string"
        ]
      }
    ],
    "previous": {
      "id": "1868c14b",
      "type": "InvalidArgumentException",
      "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php",
      "line": 257,
      "message": "Session ID already exists",
      "code": 0,
      "url": "/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=raw&ctype=text/javascript",
      "backtrace": [
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php",
          "line": 223,
          "function": "getEmptySessionInternal",
          "class": "MediaWiki\\Session\\SessionManager",
          "type": "->",
          "args": [
            "WebRequest",
            "string"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/WebRequest.php",
          "line": 658,
          "function": "getSessionById",
          "class": "MediaWiki\\Session\\SessionManager",
          "type": "->",
          "args": [
            "string",
            "boolean",
            "WebRequest"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php",
          "line": 1149,
          "function": "getSession",
          "class": "WebRequest",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php",
          "line": 359,
          "function": "loadFromSession",
          "class": "User",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php",
          "line": 5020,
          "function": "load",
          "class": "User",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php",
          "line": 2606,
          "function": "loadOptions",
          "class": "User",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/context/RequestContext.php",
          "line": 368,
          "function": "getOption",
          "class": "User",
          "type": "->",
          "args": [
            "string"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/Message.php",
          "line": 648,
          "function": "getLanguage",
          "class": "RequestContext",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/context/RequestContext.php",
          "line": 462,
          "function": "setContext",
          "class": "Message",
          "type": "->",
          "args": [
            "RequestContext"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/context/ContextSource.php",
          "line": 186,
          "function": "msg",
          "class": "RequestContext",
          "type": "->",
          "args": [
            "string"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/OutputPage.php",
          "line": 1000,
          "function": "msg",
          "class": "ContextSource",
          "type": "->",
          "args": [
            "string"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/actions/Action.php",
          "line": 355,
          "function": "setPageTitle",
          "class": "OutputPage",
          "type": "->",
          "args": [
            "string"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/actions/FormlessAction.php",
          "line": 38,
          "function": "setHeaders",
          "class": "Action",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php",
          "line": 494,
          "function": "show",
          "class": "FormlessAction",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php",
          "line": 286,
          "function": "performAction",
          "class": "MediaWiki",
          "type": "->",
          "args": [
            "Article",
            "Title"
          ]
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php",
          "line": 738,
          "function": "performRequest",
          "class": "MediaWiki",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php",
          "line": 510,
          "function": "main",
          "class": "MediaWiki",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/php-1.27.0-wmf.11/index.php",
          "line": 43,
          "function": "run",
          "class": "MediaWiki",
          "type": "->",
          "args": []
        },
        {
          "file": "/srv/mediawiki/w/index.php",
          "line": 3,
          "function": "include",
          "args": [
            "string"
          ]
        }
      ]
    },
    "exception_id": "9564be87",
    "class": "mediawiki",
    "message_checksum": "e9ca78920ae33253dffd58a42c18f46e",
    "normalized_message": "Can neither load the session nor create an empty session"
  },
  "sort": [
    1453261416000
  ]
}
bd808 added a comment.Jan 20 2016, 4:06 AM

My ES-fu is too weak to get a list of distinct URLs but just by eyeballing it seems to be limited to action=raw (JS pages) and Special:CentralAutoLogin/start.

Here's a logstash dashboard that includes a breakdown down by URL: https://logstash.wikimedia.org/#/dashboard/elasticsearch/T124126

 {
  "function": "shutdown",
  "class": "MediaWiki\\Session\\SessionManager",
  "type": "->",
  "args": []
}

Do they all start with that?

Looks like a little more than half of them do. (breakout in dashboard)

Tgr added a comment.Jan 20 2016, 8:03 AM

Here are the traces in nice form:
CentralAuth:

2016-01-20 07:50:43 mw1084 mediawikiwiki exception ERROR: [51dab482] /wiki/Special:CentralAutoLogin/setCookies?type=1x1&from=commonswiki&proto=https   UnexpectedValueException from line 232 of /srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php: Can neither load the session nor create an empty session {"exception_id":"51dab482"} 
[Exception UnexpectedValueException] (/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php:232) Can neither load the session nor create an empty session
  #0 /srv/mediawiki/php-1.27.0-wmf.11/includes/session/PHPSessionHandler.php(239): MediaWiki\Session\SessionManager->getSessionById(string)
  #1 [internal function]: MediaWiki\Session\PHPSessionHandler->write(string, string)
  #2 [internal function]: call_user_func(array, string, string)
  #3 [internal function]: __SystemLib\SessionForwardingHandler->write(string, string)
  #4 /srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php(592): session_write_close()
  #5 [internal function]: MediaWiki\Session\SessionManager->shutdown()
  #6 {main}
Caused by: [Exception InvalidArgumentException] (/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php:257) Session ID already exists
  #0 /srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php(223): MediaWiki\Session\SessionManager->getEmptySessionInternal(FauxRequest, string)
  #1 /srv/mediawiki/php-1.27.0-wmf.11/includes/session/PHPSessionHandler.php(239): MediaWiki\Session\SessionManager->getSessionById(string)
  #2 [internal function]: MediaWiki\Session\PHPSessionHandler->write(string, string)
  #3 [internal function]: call_user_func(array, string, string)
  #4 [internal function]: __SystemLib\SessionForwardingHandler->write(string, string)
  #5 /srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php(592): session_write_close()
  #6 [internal function]: MediaWiki\Session\SessionManager->shutdown()
  #7 {main}

JS:

2016-01-20 07:50:47 mw1238 mediawikiwiki exception ERROR: [859ea26b] /w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript   UnexpectedValueException from line 232 of /srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php: Can neither load the session nor create an empty session {"exception_id":"859ea26b"} 
[Exception UnexpectedValueException] (/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php:232) Can neither load the session nor create an empty session
  #0 /srv/mediawiki/php-1.27.0-wmf.11/includes/WebRequest.php(658): MediaWiki\Session\SessionManager->getSessionById(string, boolean, WebRequest)
  #1 /srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php(1149): WebRequest->getSession()
  #2 /srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php(359): User->loadFromSession()
  #3 /srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php(5020): User->load()
  #4 /srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php(2606): User->loadOptions()
  #5 /srv/mediawiki/php-1.27.0-wmf.11/includes/context/RequestContext.php(368): User->getOption(string)
  #6 /srv/mediawiki/php-1.27.0-wmf.11/includes/Message.php(648): RequestContext->getLanguage()
  #7 /srv/mediawiki/php-1.27.0-wmf.11/includes/context/RequestContext.php(462): Message->setContext(RequestContext)
  #8 /srv/mediawiki/php-1.27.0-wmf.11/includes/context/ContextSource.php(186): RequestContext->msg(string)
  #9 /srv/mediawiki/php-1.27.0-wmf.11/includes/OutputPage.php(1000): ContextSource->msg(string)
  #10 /srv/mediawiki/php-1.27.0-wmf.11/includes/actions/Action.php(355): OutputPage->setPageTitle(string)
  #11 /srv/mediawiki/php-1.27.0-wmf.11/includes/actions/FormlessAction.php(38): Action->setHeaders()
  #12 /srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php(494): FormlessAction->show()
  #13 /srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php(286): MediaWiki->performAction(Article, Title)
  #14 /srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php(738): MediaWiki->performRequest()
  #15 /srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php(510): MediaWiki->main()
  #16 /srv/mediawiki/php-1.27.0-wmf.11/index.php(43): MediaWiki->run()
  #17 /srv/mediawiki/w/index.php(3): include(string)
  #18 {main}
Caused by: [Exception InvalidArgumentException] (/srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php:257) Session ID already exists
  #0 /srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php(223): MediaWiki\Session\SessionManager->getEmptySessionInternal(WebRequest, string)
  #1 /srv/mediawiki/php-1.27.0-wmf.11/includes/WebRequest.php(658): MediaWiki\Session\SessionManager->getSessionById(string, boolean, WebRequest)
  #2 /srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php(1149): WebRequest->getSession()
  #3 /srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php(359): User->loadFromSession()
  #4 /srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php(5020): User->load()
  #5 /srv/mediawiki/php-1.27.0-wmf.11/includes/user/User.php(2606): User->loadOptions()
  #6 /srv/mediawiki/php-1.27.0-wmf.11/includes/context/RequestContext.php(368): User->getOption(string)
  #7 /srv/mediawiki/php-1.27.0-wmf.11/includes/Message.php(648): RequestContext->getLanguage()
  #8 /srv/mediawiki/php-1.27.0-wmf.11/includes/context/RequestContext.php(462): Message->setContext(RequestContext)
  #9 /srv/mediawiki/php-1.27.0-wmf.11/includes/context/ContextSource.php(186): RequestContext->msg(string)
  #10 /srv/mediawiki/php-1.27.0-wmf.11/includes/OutputPage.php(1000): ContextSource->msg(string)
  #11 /srv/mediawiki/php-1.27.0-wmf.11/includes/actions/Action.php(355): OutputPage->setPageTitle(string)
  #12 /srv/mediawiki/php-1.27.0-wmf.11/includes/actions/FormlessAction.php(38): Action->setHeaders()
  #13 /srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php(494): FormlessAction->show()
  #14 /srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php(286): MediaWiki->performAction(Article, Title)
  #15 /srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php(738): MediaWiki->performRequest()
  #16 /srv/mediawiki/php-1.27.0-wmf.11/includes/MediaWiki.php(510): MediaWiki->main()
  #17 /srv/mediawiki/php-1.27.0-wmf.11/index.php(43): MediaWiki->run()
  #18 /srv/mediawiki/w/index.php(3): include(string)
  #19 {main}

The CentralAuth one seems relatively harmless as it's called in the shutdown handler and those CA special pages start a new session so they should call persist() and not leave saving the session to the handler. The other probably breaks the gadget loading the script, but well-maintained gadgets tend to use ResourceLoader and only older ones are affected, so that's also not house on fire category.

Good, the "session" log channel is in logstash.

Looking through logs to that channel time-correlated with the one corresponding to the exception, what I think might be happening here is that if the session exists but can't be loaded because the user's token has changed, SessionManager::getSessionById() fails to fetch the current session and can't create a new session with that same ID. The solution, IMO, is to make this an expected situation rather than an exceptional one and adjust callers to take it into account.

Change 265297 had a related patch set uploaded (by Anomie):
SessionManager: Change behavior of getSessionById()

https://gerrit.wikimedia.org/r/265297

greg added a subscriber: greg.Jan 20 2016, 9:54 PM

Change 265297 merged by jenkins-bot:
SessionManager: Change behavior of getSessionById()

https://gerrit.wikimedia.org/r/265297

Change 265404 had a related patch set uploaded (by Gergő Tisza):
SessionManager: Change behavior of getSessionById()

https://gerrit.wikimedia.org/r/265404

Change 265404 merged by jenkins-bot:
SessionManager: Change behavior of getSessionById()

https://gerrit.wikimedia.org/r/265404

Tgr added a comment.EditedJan 21 2016, 12:08 AM

The patch cleared the exceptions; we now have a bunch of Warning: Failed to write session data (user). Please verify that the current setting of session.save_path is correct () in /srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php on line 588 in fatalmonitor. That's an expected side effect (instead of throwing an exception, session write fails now) but 1) eventually we should reduce the noise somwehow, 2) I'm a bit baffled that I don't see the Session XXX cannot be loaded, skipping write messages on the session log channel that I would expect to come with that. (The failed to create empty session: Session ID already exists log events are there.)

The patch cleared the exceptions; we now have a bunch of Warning: Failed to write session data (user). Please verify that the current setting of session.save_path is correct () in /srv/mediawiki/php-1.27.0-wmf.11/includes/session/SessionManager.php on line 588 in fatalmonitor. That's an expected side effect (instead of throwing an exception, session write fails now) but 1) eventually we should reduce the noise somwehow,

The simple hack would be to return true instead of false from PHPSessionHandler::write().

  1. I'm a bit baffled that I don't see the Session XXX cannot be loaded, skipping write messages on the session log channel that I would expect to come with that. (The failed to create empty session: Session ID already exists log events are there.)

No idea. If it's still a concern tomorrow, remind me in the morning and I'll see if I can figure it out.

Change 265480 had a related patch set uploaded (by Gergő Tisza):
Do not raise a PHP warning when session write fails

https://gerrit.wikimedia.org/r/265480

Change 265480 merged by jenkins-bot:
Do not raise a PHP warning when session write fails

https://gerrit.wikimedia.org/r/265480

Change 265523 had a related patch set uploaded (by Dduvall):
Do not raise a PHP warning when session write fails

https://gerrit.wikimedia.org/r/265523

Change 265523 merged by jenkins-bot:
Do not raise a PHP warning when session write fails

https://gerrit.wikimedia.org/r/265523

I wonder if these errors I am seeing for Special:ChangePassword in translatewiki.net are related:

2016-01-21 07:09:29 translatewiki.net translatewiki_net-bw_: Exception thrown with an uncommited database transaction: [9e392a5a] /wiki/Special:ChangePassword   UnexpectedValueException from line 232 of /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/SessionManager.php: Can neither load the session nor create an empty session
#0 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/WebRequest.php(658): MediaWiki\Session\SessionManager->getSessionById(string, boolean, WebRequest)
#1 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/WebRequest.php(963): WebRequest->getSession()
#2 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/specials/SpecialUserlogin.php(1600): WebRequest->setSessionData(string, NULL)
#3 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/specials/SpecialUserlogin.php(1001): LoginForm::clearLoginToken()
#4 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/specials/SpecialUserlogin.php(361): LoginForm->processLogin()
#5 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/specials/SpecialChangePassword.php(232): LoginForm->execute(NULL)
#6 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/specialpage/FormSpecialPage.php(155): SpecialChangePassword->onSuccess()
#7 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/specials/SpecialChangePassword.php(55): FormSpecialPage->execute(NULL)
#8 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/specialpage/SpecialPage.php(384): SpecialChangePassword->execute(NULL)
#9 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/specialpage/SpecialPageFactory.php(563): SpecialPage->run(NULL)
#10 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/MediaWiki.php(280): SpecialPageFactory::executePath(Title, RequestContext)
#11 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/MediaWiki.php(738): MediaWiki->performRequest()
#12 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/MediaWiki.php(510): MediaWiki->main()
#13 /srv/mediawiki/tags/2016-01-19_16:04:04/index.php(43): MediaWiki->run()
#14 {main}

[Thu Jan 21 08:09:29 2016] [hphp] [5303:7f846a7ff700:10807:000001] [] \nFatal error: Uncaught exception 'InvalidArgumentException' with message 'Session ID already exists' in /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/SessionManager.php:257\nStack trace:\n#0 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/SessionManager.php(223): MediaWiki\\Session\\SessionManager->getEmptySessionInternal()\n#1 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/PHPSessionHandler.php(239): MediaWiki\\Session\\SessionManager->getSessionById()\n#2 (): MediaWiki\\Session\\PHPSessionHandler->write()\n#3 (): call_user_func()\n#4 (): __SystemLib\\SessionForwardingHandler->write()\n#5 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/SessionManager.php(592): session_write_close()\n#6 (): MediaWiki\\Session\\SessionManager->shutdown()\n#7 {main}\n\nNext exception 'UnexpectedValueException' with message 'Can neither load the session nor create an empty session' in /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/SessionManager.php:232\nStack trace:\n#0 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/PHPSessionHandler.php(239): MediaWiki\\Session\\SessionManager->getSessionById()\n#1 (): MediaWiki\\Session\\PHPSessionHandler->write()\n#2 (): call_user_func()\n#3 (): __SystemLib\\SessionForwardingHandler->write()\n#4 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/SessionManager.php(592): session_write_close()\n#5 (): MediaWiki\\Session\\SessionManager->shutdown()\n#6 {main}
2016-01-21 07:09:29 translatewiki.net translatewiki_net-bw_: [99d843ee] /wiki/Special:ChangePassword   UnexpectedValueException from line 232 of /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/SessionManager.php: Can neither load the session nor create an empty session
#0 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/PHPSessionHandler.php(239): MediaWiki\Session\SessionManager->getSessionById(string)
#1 [internal function]: MediaWiki\Session\PHPSessionHandler->write(string, string)
#2 [internal function]: call_user_func(array, string, string)
#3 [internal function]: __SystemLib\SessionForwardingHandler->write(string, string)
#4 /srv/mediawiki/tags/2016-01-20_16:16:23/includes/session/SessionManager.php(592): session_write_close()
#5 [internal function]: MediaWiki\Session\SessionManager->shutdown()
#6 {main}
Tgr added a comment.Jan 21 2016, 8:11 PM

@Nikerabbit: yes but should be fixed in current master / wmf.11.

Anomie closed this task as Resolved.Jan 23 2016, 7:10 PM
Anomie claimed this task.
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:11 PM