概述
用戶反饋在 Notebook 上無(wú)法創(chuàng)建 ipynb 文件,并且會(huì)返回以下的錯(cuò)誤。
報(bào)錯(cuò)的信息是: Unexpected error while saving file: Untitled5.ipynb attempt to write a readonly database
排查問(wèn)題
這個(gè)是一個(gè)比較新的問(wèn)題,因?yàn)閳F(tuán)隊(duì)之前也沒(méi)有人遇見(jiàn)過(guò),不過(guò)通過(guò)報(bào)錯(cuò)信息,很容易定位到這個(gè) issue Creating Jupyter Notebook Failed: error to write a readonly database #5321。初步看,我們這里遇到的問(wèn)題跟 issue 上是一樣的。
雖然沒(méi)有仔細(xì)看過(guò) Jupyterhub 和 Jupyterlab 的代碼,但是我們可以根據(jù)一些報(bào)錯(cuò)信息來(lái)進(jìn)行進(jìn)一步的排查。
[I 2024-01-18 09:48:31.909 SingleUserLabApp handlers:172] Creating new notebook in
[E 2024-01-18 09:48:31.910 SingleUserLabApp filemanager:449] Error while saving file: Untitled5.ipynb attempt to write a readonly database
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/jupyter_server/services/contents/filemanager.py", line 434, in save
self.check_and_sign(nb, path)
File "/usr/local/lib/python3.9/site-packages/jupyter_server/services/contents/manager.py", line 651, in check_and_sign
self.notary.sign(nb)
File "/usr/local/lib/python3.9/site-packages/nbformat/sign.py", line 462, in sign
self.store.store_signature(signature, self.algorithm)
File "/usr/local/lib/python3.9/site-packages/nbformat/sign.py", line 204, in store_signature
if not self.check_signature(digest, algorithm):
File "/usr/local/lib/python3.9/site-packages/nbformat/sign.py", line 239, in check_signature
self.db.execute(
sqlite3.OperationalError: attempt to write a readonly database
[W 2024-01-18 09:48:31.910 SingleUserLabApp web:1796] 500 POST /user/oscar01.liu/api/contents?1705542511901 (10.80.50.125): Unexpected error while saving file: Untitled5.ipynb attempt to write a readonly database
[W 2024-01-18 09:48:31.910 SingleUserLabApp handlers:649] Unexpected error while saving file: Untitled5.ipynb attempt to write a readonly database
[E 2024-01-18 09:48:31.911 SingleUserLabApp log:178] {
"Cookie": "jupyterhub-user-oscar01.liu=[secret]; _xsrf=[secret]; jupyterhub-user-oscar01.liu-oauth-state=[secret]",
"Accept-Language": "zh-CN,zh;q=0.9",
"Accept-Encoding": "gzip, deflate",
"Referer": "http://gd17-llm-002-jupyterhub.xxx.com/user/oscar01.liu/lab/workspaces/auto-P",
"Origin": "http://gd17-llm-002-jupyterhub.xxx.com",
"Accept": "*/*",
"Content-Type": "text/plain;charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Authorization": "token [secret]",
"X-Xsrftoken": "2|b9010b04|67edc801549f9be14554782ddb629233|1703062619",
"Content-Length": "29",
"X-Scheme": "http",
"X-Forwarded-Proto": "http,http",
"X-Forwarded-Port": "80,80",
"X-Forwarded-Host": "gd17-llm-002-jupyterhub.xxx.com",
"X-Forwarded-For": "10.80.50.125,10.122.196.115",
"X-Real-Ip": "10.80.50.125",
"X-Request-Id": "e6b76c0d4424e0f93a90fd0b10fc473b",
"Host": "gd17-llm-002-jupyterhub.xxx.com",
"Connection": "close"
}
當(dāng)嘗試創(chuàng)建 ipynb 文件的時(shí)候,Notebook 的容器會(huì)打出報(bào)錯(cuò)的日志,從日志上看,感覺(jué)就是創(chuàng)建 ipynb 的時(shí)候,Notebook 會(huì)有讀寫(xiě)數(shù)據(jù)庫(kù)這樣的操作,結(jié)合 issue 和用戶的行為,大概可以判斷,是因?yàn)橛脩魟?dòng)了 $HOME/.local/share/jupyter
目錄下的一些配置文件,而這個(gè)目錄內(nèi),有一個(gè) sqlite3 實(shí)現(xiàn)的內(nèi)存數(shù)據(jù)庫(kù),會(huì)記錄一些本地 Notebook 的信息,這個(gè)文件就是 nbsignatures.db,如下圖。
我們可以通過(guò) python 來(lái)打開(kāi)這 db 文件,查看一下,具體有什么信息在里面,具體的代碼如下。
import sqlite3
# 連接到 SQLite 數(shù)據(jù)庫(kù)文件
conn = sqlite3.connect('$HOME/.local/share/jupyter/nbsignatures.db')
# 創(chuàng)建一個(gè) cursor
cursor = conn.cursor()
# 查詢 nbsignatures 表的所有數(shù)據(jù)
print("Data in nbsignatures table:")
cursor.execute("SELECT * FROM nbsignatures;")
for row in cursor.fetchall():
print(row)
# 關(guān)閉 cursor 和連接
cursor.close()
conn.close()
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-804612.html
恢復(fù)方法
恢復(fù)的手段,要么是讓用戶把相關(guān)的文件和文件目錄恢復(fù),如果實(shí)在無(wú)法找回,最好的辦法就是重啟一下 Notebook 的容器了。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-804612.html
參考資料
- Creating Jupyter Notebook Failed: error to write a readonly database #5321
到了這里,關(guān)于Jupyter-Notebook無(wú)法創(chuàng)建ipynb文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!