Skip to content

Commit

Permalink
[State] Disable WAL when running on WSL (#1574)
Browse files Browse the repository at this point in the history
* Add check for WSL before enabling WAL

* Add check for WSL before enabling WAL for sqlite

* fix import lint

* comments
  • Loading branch information
romilbhardwaj authored Jan 10, 2023
1 parent 9f2bf1d commit fd16154
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion sky/global_user_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
def create_table(cursor, conn):
# Enable WAL mode to avoid locking issues.
# See: issue #1441 and PR #1509
conn.execute('PRAGMA journal_mode=WAL')
# 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():
conn.execute('PRAGMA journal_mode=WAL')
# Table for Clusters
cursor.execute("""\
CREATE TABLE IF NOT EXISTS clusters (
Expand Down
10 changes: 8 additions & 2 deletions sky/utils/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import functools
import getpass
import inspect
import hashlib
import inspect
import json
import random
import os
import platform
import random
import re
import socket
import sys
Expand Down Expand Up @@ -352,3 +353,8 @@ def remove_file_if_exists(path: str):
except FileNotFoundError:
logger.debug(f'Tried to remove {path} but failed to find it. Skip.')
pass


def is_wsl() -> bool:
"""Detect if running under Windows Subsystem for Linux (WSL)."""
return 'microsoft' in platform.uname()[3].lower()

0 comments on commit fd16154

Please sign in to comment.