Skip to content

Commit

Permalink
[Core] Turn on WAL mode for cluster job table (#3923)
Browse files Browse the repository at this point in the history
* fix: add retry wrapper around db operation

* fix: enable wal mode for job table

* fix: remove retries from db utils

* fix: add WAL to jobs table

* fix: tidy up formatting
  • Loading branch information
wizenheimer authored Oct 14, 2024
1 parent e4b7df7 commit 340f384
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sky/skylet/job_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import pathlib
import shlex
import sqlite3
import subprocess
import time
import typing
Expand Down Expand Up @@ -55,6 +56,20 @@ class JobInfoLoc(enum.IntEnum):


def create_table(cursor, conn):
# Enable WAL mode to avoid locking issues.
# See: issue #3863, #1441 and PR #1509
# https://github.com/microsoft/WSL/issues/2395
# TODO(romilb): We do not enable WAL for WSL because of known issue in WSL.
# This may cause the database locked problem from WSL issue #1441.
if not common_utils.is_wsl():
try:
cursor.execute('PRAGMA journal_mode=WAL')
except sqlite3.OperationalError as e:
if 'database is locked' not in str(e):
raise
# If the database is locked, it is OK to continue, as the WAL mode
# is not critical and is likely to be enabled by other processes.

cursor.execute("""\
CREATE TABLE IF NOT EXISTS jobs (
job_id INTEGER PRIMARY KEY AUTOINCREMENT,
Expand Down

0 comments on commit 340f384

Please sign in to comment.