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

[QUESTION]RedLock多次运行崩溃的现象 #624

Closed
cmoth150415 opened this issue Mar 4, 2025 · 2 comments
Closed

[QUESTION]RedLock多次运行崩溃的现象 #624

cmoth150415 opened this issue Mar 4, 2025 · 2 comments

Comments

@cmoth150415
Copy link

cmoth150415 commented Mar 4, 2025

官网上RedLock的示例代码,在centos下如果连续调用的话,总会在某一次卡死,请问可能是什么原因?

	for (int i = 0; i < 1000; i++) {
		sw::redis::RedMutexOptions opts;
		opts.ttl = std::chrono::seconds(5);
		auto watcher = std::make_shared<sw::redis::LockWatcher>();
		// Create a `RedMutex` with auto_extend_err_callback and other options.
		sw::redis::RedMutex mtx({ conn }, lock_key,
			[](std::exception_ptr err) {
				try {
					//std::rethrow_exception(err);
				}
				catch (const Error& e) {
					// Notify application code that the lock might no longer be locked.
				}
			},
			opts, watcher);
		std::unique_lock<RedMutex> lock(mtx, std::defer_lock);
                // ... other code
     }
@sewenew
Copy link
Owner

sewenew commented Mar 5, 2025

可以先升级到最新的redis-plus-plus试试,老版本的可能有问题。我用最新的redis-plus-plus,直接测试这个代码,无法复现

如果还是有问题,请提供一段最小的,可以编译通过,稳定复现的代码。谢谢!

Regards

@sewenew
Copy link
Owner

sewenew commented Mar 17, 2025

Close the issue, since there's no update.

Regards

@sewenew sewenew closed this as completed Mar 17, 2025
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

No branches or pull requests

2 participants