byzer-org / byzer-notebook

Apache License 2.0
46 stars 34 forks source link

[BUG]create duplicate Notebooks when create a New Notebook #158

Open kid0401 opened 2 years ago

kid0401 commented 2 years ago

When I created a New Notebook "Zoho", it was copied by 11 times ,like this:

图片

However, Normally, Byzer-notebook does not allow duplicate names. I saw the table of database ,like this: 图片

And found some errors in the log ,like this: 图片

I hope these can help find the problem.

MichelZhan commented 2 years ago

@ZhengshuaiPENG @chncaesar

Image

排查 access_log 发现实际发送了多次 创建notebook请求,而从前面的日志可以看到,此时数据库性能也有问题,简单查询都变成慢查询。原本在NotebookService.create 中创建notebook前会查询notebook_info中的记录,做重名判断,在此查询全部变慢的情况下此逻辑失效,多个创建notebook的事务同时执行,进而创建出很多同名notebook。 方案一,给notebook_info表加 unique索引,user+notebook_name+folder_id 作为唯一索引。但之前根目录folder_id默认是空值,这样的唯一索引是无效的。如果把默认folder_id改成其他值会涉及到元数据改动,前后端也要做调整,风险较大。 方案二,考虑到上面方案可能存在较大风险,现阶段可现在前端做并发控制。