codeigniter4 / codeigniter4/CodeIgniter4

Bug: [Memcached] session_start(): Unable to clear session lock record

Open
#7,604 4 comments 0 reactions 0 assignees View on GitHub
bug can of worms
Dominant language
PHP
Stars
6k
Forks
2k
Avg merge
1d 11h
Merged PRs (30d)
73

Description

### PHP Version

8.2

### CodeIgniter4 Version

4.3.2

### CodeIgniter4 Installation Method

Composer (using `codeigniter4/appstarter`)

### Which operating systems have you tested for this bug?

Linux

### Which server did you use?

fpm-fcgi

### Database

Mysql 5.7

### What happened?

I have configured session store as memcached, it was working fine in PHP 7.1 with codeIgniter 2,

After upgrading PHP 7.1 to 8.2 and codeIgniter 2 to 4 I am getting an error on multiple async ajax call

```
session_start(): Unable to clear session lock record
in SYSTEMPATH/Session/Session.php on line 928.
1 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler()
2 SYSTEMPATH/Session/Session.php(928): session_start()
3 SYSTEMPATH/Session/Session.php(250): CodeIgniter\Session\Session->startSession()
4 SYSTEMPATH/Config/Services.php(674): CodeIgniter\Session\Session->start()
5 SYSTEMPATH/Config/BaseService.php(252): CodeIgniter\Config\Services::session()
6 SYSTEMPATH/Config/BaseService.php(193): CodeIgniter\Config\BaseService::__callStatic()
7 SYSTEMPATH/Config/Services.php(641): CodeIgniter\Config\BaseService::getSharedInstance()
8 SYSTEMPATH/Config/BaseService.php(252): CodeIgniter\Config\Services::session()
9 SYSTEMPATH/Common.php(988): CodeIgniter\Config\BaseService::__callStatic()
```

codeIgniter official website also suggests to use session_write_close() for resolving this issue. But this did not work for ajax concurrent call.

### Steps to Reproduce

When I am calling multiple sync ajax than getting error

### Expected Output

Getting Json Response

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at SYSTEMPATH/Session/Session.php line 928 and trace the startSession() path that calls session_start(). Reproduce the failure with Memcached during multiple concurrent AJAX requests on PHP 8.2 and compare the behavior with the expected JSON response. The issue is resolved when concurrent requests no longer report the session lock-record error.

Written by the indexing model from the issue text.

Assessment

Tech stack
memcached, php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.