Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timer table set failed #650

Merged
merged 2 commits into from
Mar 1, 2023
Merged

Fix timer table set failed #650

merged 2 commits into from
Mar 1, 2023

Conversation

sy-records
Copy link
Contributor

Fix #648

The maximum number of rows a table can store is positively related to $size, but not exactly the same, e.g. $size is 1024 and the actual number of rows that can be stored is less than 1024.

So add a configuration item and let the user go and configure it according to the actual situation.

This code can be used to reproduce the problem.

use Swoole\Table;

$table = new Table(1024);
$table->column('worker_pid', Table::TYPE_INT);
$table->column('time', Table::TYPE_INT);
$table->column('fd', Table::TYPE_INT);

$table->create();

foreach (range(1, 1050) as $i) {
    $table->set($i, [
        'worker_pid' => $i,
        'time' => time(),
        'fd' => $i,
    ]);
}

var_dump($table->stats(), $table->getSize());

Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sy-records

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Swoole\Table::set(): failed to set('161'), unable to allocate memory Due to fixed table size
3 participants