We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
test_upgrade_db_22_to_23_without_frontend_settings fails in OSX tests
## Problem Definition

We noticed this in the nightly runs here: https://github.com/rotki/rotki/runs/1811061566?check_suite_focus=true

It fails only in OSX and has never failed in linux.

```
______________ test_upgrade_db_22_to_23_without_frontend_settings ______________

data_dir = PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir')
user_data_dir = PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir/testuser')

    def test_upgrade_db_22_to_23_without_frontend_settings(data_dir, user_data_dir):
        """Test upgrading the DB from version 22 to version 23.
    
        Tests the case where frontend settings were not populated and also the cache
        file movement and deletion. Also test deleletion of deprecated historical_data_start
        """
        msg_aggregator = MessagesAggregator()
        _use_prepared_db(user_data_dir, 'v22_rotkehlchen_wo_frontend_settings.db')
        db_v22 = _init_db_with_target_version(
            target_version=22,
            user_data_dir=user_data_dir,
            msg_aggregator=msg_aggregator,
        )
        cursor = db_v22.conn.cursor()
    
        # Create cache files under the data directory
        (data_dir / 'forex_history_file.json').touch()
        (data_dir / 'price_history_BTC_EUR.json').touch()
        (data_dir / 'price_history_aDAI_USD.json').touch()
        (data_dir / 'price_history_YFI_USD.json').touch()
        # Also create an innocent json file and a random file
        (data_dir / 'random.json').touch()
        (data_dir / 'random.txt').touch()
        # Check all settings except 'frontend_settings' exist
        assert cursor.execute(
            'SELECT COUNT(*) FROM settings WHERE name = "frontend_settings";',
        ).fetchone()[0] == 0
        assert cursor.execute(
            'SELECT COUNT(*) FROM settings WHERE name IN '
            '("thousand_separator", "decimal_separator", "currency_location");',
        ).fetchone()[0] == 3
        # Check we got a historical data start entry to remove
        assert cursor.execute(
            'SELECT COUNT(*) FROM settings WHERE name = "historical_data_start";',
        ).fetchone()[0] == 1
    
        # Migrate to v23
        db = _init_db_with_target_version(
            target_version=23,
            user_data_dir=user_data_dir,
            msg_aggregator=msg_aggregator,
        )
        cursor = db.conn.cursor()
    
        # Make sure the settings have been removed
        assert cursor.execute(
            'SELECT COUNT(*) FROM settings WHERE name IN '
            '("thousand_separator", "decimal_separator", "currency_location");',
        ).fetchone()[0] == 0
        assert cursor.execute(
            'SELECT COUNT(*) FROM settings WHERE name = "historical_data_start";',
        ).fetchone()[0] == 0
    
        # Make sure the settings have been migrated into 'frontend_settings'
        frontend_settings = cursor.execute(
            'SELECT value FROM settings WHERE name = "frontend_settings";',
        ).fetchone()[0]
        frontend_settings_map = json.loads(frontend_settings)
        assert frontend_settings_map['thousand_separator'] == ','
        assert frontend_settings_map['decimal_separator'] == '.'
        assert frontend_settings_map['currency_location'] == 'after'
    
        # Assure the cache files were deleted
        assert not (data_dir / 'price_history_BTC_EUR.json').is_file()
        assert not (data_dir / 'price_history_aDAI_USD.json').is_file()
        assert not (data_dir / 'price_history_YFI_USD.json').is_file()
        # and that the forex history cache file moved
>       assert (data_dir / 'price_history' / 'forex_history_file.json').is_file()
E       AssertionError: assert False
E        +  where False = <bound method Path.is_file of PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir/price_history/forex_history_file.json')>()
E        +    where <bound method Path.is_file of PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir/price_history/forex_history_file.json')> = ((PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir') / 'price_history') / 'forex_history_file.json').is_file

rotkehlchen/tests/db/test_db_upgrades.py:1311: AssertionError
```

## Task

Figure out why and fix it

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rotkehlchen/db/upgrades/v22_v23.py`
Content:
```
1 import json
2 from typing import TYPE_CHECKING
3 from rotkehlchen.utils.misc import get_or_make_price_history_dir
4 import os
5 from pathlib import Path
6 import glob
7 import shutil
8 
9 if TYPE_CHECKING:
10     from rotkehlchen.db.dbhandler import DBHandler
11 
12 
13 def upgrade_v22_to_v23(db: 'DBHandler') -> None:
14     """Upgrades the DB from v22 to v23
15 
16     - Migrates the settings entries 'thousand_separator', 'decimal_separator'
17     and 'currency_location' into the 'frontend_settings' entry.
18     - Deletes Bitfinex trades and their used query range, so trades can be
19     populated again with the right `fee_asset`.
20     - Delete all cryptocompare price cache files. Move forex price cache to price_history directory
21     """
22     settings = ('"thousand_separator"', '"decimal_separator"', '"currency_location"')
23     cursor = db.conn.cursor()
24     # Get the settings and put them in a dict
25     setting_value_map = dict(
26         cursor.execute(
27             f'SELECT name, value FROM settings WHERE name IN ({",".join(settings)});',
28         ).fetchall(),
29     )
30     # If the settings exist, migrate them into the 'frontend_settings' entry
31     if setting_value_map:
32         frontend_settings = cursor.execute(
33             'SELECT value FROM settings WHERE name = "frontend_settings";',
34         ).fetchone()
35 
36         if frontend_settings is not None:
37             setting_value_map.update(json.loads(frontend_settings[0]))
38 
39         cursor.execute(
40             'INSERT OR REPLACE INTO settings(name, value) VALUES(?, ?)',
41             ('frontend_settings', json.dumps(setting_value_map)),
42         )
43     # Delete the settings
44     cursor.execute(f'DELETE FROM settings WHERE name IN ({",".join(settings)});')
45     # Delete Bitfinex used_query_ranges
46     cursor.execute('DELETE FROM used_query_ranges WHERE name = "bitfinex_trades";')
47     # Delete Bitfinex trades
48     cursor.execute('DELETE FROM trades WHERE location = "T";')
49     # Delete deprecated historical data start setting
50     cursor.execute('DELETE from settings WHERE name="historical_data_start";')
51     db.conn.commit()
52 
53     # -- Now move forex history to the new directory and remove all old cache files
54     data_directory = db.user_data_dir.parent
55     price_history_dir = get_or_make_price_history_dir(data_directory)
56     forex_history_file = data_directory / 'price_history_forex.json'
57     if forex_history_file.is_file():
58         shutil.move(
59             forex_history_file,  # type: ignore
60             price_history_dir / 'forex_history_file.json',
61         )
62 
63     prefix = os.path.join(str(data_directory), 'price_history_')
64     prefix = prefix.replace('\\', '\\\\')
65     files_list = glob.glob(prefix + '*.json')
66     for file_ in files_list:
67         file_ = file_.replace('\\\\', '\\')
68         try:
69             Path(file_).unlink()
70         except OSError:
71             pass
72
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/rotkehlchen/db/upgrades/v22_v23.py b/rotkehlchen/db/upgrades/v22_v23.py
--- a/rotkehlchen/db/upgrades/v22_v23.py
+++ b/rotkehlchen/db/upgrades/v22_v23.py
@@ -51,6 +51,8 @@
     db.conn.commit()
 
     # -- Now move forex history to the new directory and remove all old cache files
+    # We botched this. Should have been forex_history_file.json -> price_history_forex.json
+    # and not the other way around
     data_directory = db.user_data_dir.parent
     price_history_dir = get_or_make_price_history_dir(data_directory)
     forex_history_file = data_directory / 'price_history_forex.json'

{"golden_diff": "diff --git a/rotkehlchen/db/upgrades/v22_v23.py b/rotkehlchen/db/upgrades/v22_v23.py\n--- a/rotkehlchen/db/upgrades/v22_v23.py\n+++ b/rotkehlchen/db/upgrades/v22_v23.py\n@@ -51,6 +51,8 @@\n     db.conn.commit()\n \n     # -- Now move forex history to the new directory and remove all old cache files\n+    # We botched this. Should have been forex_history_file.json -> price_history_forex.json\n+    # and not the other way around\n     data_directory = db.user_data_dir.parent\n     price_history_dir = get_or_make_price_history_dir(data_directory)\n     forex_history_file = data_directory / 'price_history_forex.json'\n", "issue": "test_upgrade_db_22_to_23_without_frontend_settings fails in OSX tests\n## Problem Definition\r\n\r\nWe noticed this in the nightly runs here: https://github.com/rotki/rotki/runs/1811061566?check_suite_focus=true\r\n\r\nIt fails only in OSX and has never failed in linux.\r\n\r\n```\r\n______________ test_upgrade_db_22_to_23_without_frontend_settings ______________\r\n\r\ndata_dir = PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir')\r\nuser_data_dir = PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir/testuser')\r\n\r\n    def test_upgrade_db_22_to_23_without_frontend_settings(data_dir, user_data_dir):\r\n        \"\"\"Test upgrading the DB from version 22 to version 23.\r\n    \r\n        Tests the case where frontend settings were not populated and also the cache\r\n        file movement and deletion. Also test deleletion of deprecated historical_data_start\r\n        \"\"\"\r\n        msg_aggregator = MessagesAggregator()\r\n        _use_prepared_db(user_data_dir, 'v22_rotkehlchen_wo_frontend_settings.db')\r\n        db_v22 = _init_db_with_target_version(\r\n            target_version=22,\r\n            user_data_dir=user_data_dir,\r\n            msg_aggregator=msg_aggregator,\r\n        )\r\n        cursor = db_v22.conn.cursor()\r\n    \r\n        # Create cache files under the data directory\r\n        (data_dir / 'forex_history_file.json').touch()\r\n        (data_dir / 'price_history_BTC_EUR.json').touch()\r\n        (data_dir / 'price_history_aDAI_USD.json').touch()\r\n        (data_dir / 'price_history_YFI_USD.json').touch()\r\n        # Also create an innocent json file and a random file\r\n        (data_dir / 'random.json').touch()\r\n        (data_dir / 'random.txt').touch()\r\n        # Check all settings except 'frontend_settings' exist\r\n        assert cursor.execute(\r\n            'SELECT COUNT(*) FROM settings WHERE name = \"frontend_settings\";',\r\n        ).fetchone()[0] == 0\r\n        assert cursor.execute(\r\n            'SELECT COUNT(*) FROM settings WHERE name IN '\r\n            '(\"thousand_separator\", \"decimal_separator\", \"currency_location\");',\r\n        ).fetchone()[0] == 3\r\n        # Check we got a historical data start entry to remove\r\n        assert cursor.execute(\r\n            'SELECT COUNT(*) FROM settings WHERE name = \"historical_data_start\";',\r\n        ).fetchone()[0] == 1\r\n    \r\n        # Migrate to v23\r\n        db = _init_db_with_target_version(\r\n            target_version=23,\r\n            user_data_dir=user_data_dir,\r\n            msg_aggregator=msg_aggregator,\r\n        )\r\n        cursor = db.conn.cursor()\r\n    \r\n        # Make sure the settings have been removed\r\n        assert cursor.execute(\r\n            'SELECT COUNT(*) FROM settings WHERE name IN '\r\n            '(\"thousand_separator\", \"decimal_separator\", \"currency_location\");',\r\n        ).fetchone()[0] == 0\r\n        assert cursor.execute(\r\n            'SELECT COUNT(*) FROM settings WHERE name = \"historical_data_start\";',\r\n        ).fetchone()[0] == 0\r\n    \r\n        # Make sure the settings have been migrated into 'frontend_settings'\r\n        frontend_settings = cursor.execute(\r\n            'SELECT value FROM settings WHERE name = \"frontend_settings\";',\r\n        ).fetchone()[0]\r\n        frontend_settings_map = json.loads(frontend_settings)\r\n        assert frontend_settings_map['thousand_separator'] == ','\r\n        assert frontend_settings_map['decimal_separator'] == '.'\r\n        assert frontend_settings_map['currency_location'] == 'after'\r\n    \r\n        # Assure the cache files were deleted\r\n        assert not (data_dir / 'price_history_BTC_EUR.json').is_file()\r\n        assert not (data_dir / 'price_history_aDAI_USD.json').is_file()\r\n        assert not (data_dir / 'price_history_YFI_USD.json').is_file()\r\n        # and that the forex history cache file moved\r\n>       assert (data_dir / 'price_history' / 'forex_history_file.json').is_file()\r\nE       AssertionError: assert False\r\nE        +  where False = <bound method Path.is_file of PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir/price_history/forex_history_file.json')>()\r\nE        +    where <bound method Path.is_file of PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir/price_history/forex_history_file.json')> = ((PosixPath('/Users/runner/.cache/.rotkehlchen-test-dir') / 'price_history') / 'forex_history_file.json').is_file\r\n\r\nrotkehlchen/tests/db/test_db_upgrades.py:1311: AssertionError\r\n```\r\n\r\n## Task\r\n\r\nFigure out why and fix it\n", "before_files": [{"content": "import json\nfrom typing import TYPE_CHECKING\nfrom rotkehlchen.utils.misc import get_or_make_price_history_dir\nimport os\nfrom pathlib import Path\nimport glob\nimport shutil\n\nif TYPE_CHECKING:\n    from rotkehlchen.db.dbhandler import DBHandler\n\n\ndef upgrade_v22_to_v23(db: 'DBHandler') -> None:\n    \"\"\"Upgrades the DB from v22 to v23\n\n    - Migrates the settings entries 'thousand_separator', 'decimal_separator'\n    and 'currency_location' into the 'frontend_settings' entry.\n    - Deletes Bitfinex trades and their used query range, so trades can be\n    populated again with the right `fee_asset`.\n    - Delete all cryptocompare price cache files. Move forex price cache to price_history directory\n    \"\"\"\n    settings = ('\"thousand_separator\"', '\"decimal_separator\"', '\"currency_location\"')\n    cursor = db.conn.cursor()\n    # Get the settings and put them in a dict\n    setting_value_map = dict(\n        cursor.execute(\n            f'SELECT name, value FROM settings WHERE name IN ({\",\".join(settings)});',\n        ).fetchall(),\n    )\n    # If the settings exist, migrate them into the 'frontend_settings' entry\n    if setting_value_map:\n        frontend_settings = cursor.execute(\n            'SELECT value FROM settings WHERE name = \"frontend_settings\";',\n        ).fetchone()\n\n        if frontend_settings is not None:\n            setting_value_map.update(json.loads(frontend_settings[0]))\n\n        cursor.execute(\n            'INSERT OR REPLACE INTO settings(name, value) VALUES(?, ?)',\n            ('frontend_settings', json.dumps(setting_value_map)),\n        )\n    # Delete the settings\n    cursor.execute(f'DELETE FROM settings WHERE name IN ({\",\".join(settings)});')\n    # Delete Bitfinex used_query_ranges\n    cursor.execute('DELETE FROM used_query_ranges WHERE name = \"bitfinex_trades\";')\n    # Delete Bitfinex trades\n    cursor.execute('DELETE FROM trades WHERE location = \"T\";')\n    # Delete deprecated historical data start setting\n    cursor.execute('DELETE from settings WHERE name=\"historical_data_start\";')\n    db.conn.commit()\n\n    # -- Now move forex history to the new directory and remove all old cache files\n    data_directory = db.user_data_dir.parent\n    price_history_dir = get_or_make_price_history_dir(data_directory)\n    forex_history_file = data_directory / 'price_history_forex.json'\n    if forex_history_file.is_file():\n        shutil.move(\n            forex_history_file,  # type: ignore\n            price_history_dir / 'forex_history_file.json',\n        )\n\n    prefix = os.path.join(str(data_directory), 'price_history_')\n    prefix = prefix.replace('\\\\', '\\\\\\\\')\n    files_list = glob.glob(prefix + '*.json')\n    for file_ in files_list:\n        file_ = file_.replace('\\\\\\\\', '\\\\')\n        try:\n            Path(file_).unlink()\n        except OSError:\n            pass\n", "path": "rotkehlchen/db/upgrades/v22_v23.py"}], "after_files": [{"content": "import json\nfrom typing import TYPE_CHECKING\nfrom rotkehlchen.utils.misc import get_or_make_price_history_dir\nimport os\nfrom pathlib import Path\nimport glob\nimport shutil\n\nif TYPE_CHECKING:\n    from rotkehlchen.db.dbhandler import DBHandler\n\n\ndef upgrade_v22_to_v23(db: 'DBHandler') -> None:\n    \"\"\"Upgrades the DB from v22 to v23\n\n    - Migrates the settings entries 'thousand_separator', 'decimal_separator'\n    and 'currency_location' into the 'frontend_settings' entry.\n    - Deletes Bitfinex trades and their used query range, so trades can be\n    populated again with the right `fee_asset`.\n    - Delete all cryptocompare price cache files. Move forex price cache to price_history directory\n    \"\"\"\n    settings = ('\"thousand_separator\"', '\"decimal_separator\"', '\"currency_location\"')\n    cursor = db.conn.cursor()\n    # Get the settings and put them in a dict\n    setting_value_map = dict(\n        cursor.execute(\n            f'SELECT name, value FROM settings WHERE name IN ({\",\".join(settings)});',\n        ).fetchall(),\n    )\n    # If the settings exist, migrate them into the 'frontend_settings' entry\n    if setting_value_map:\n        frontend_settings = cursor.execute(\n            'SELECT value FROM settings WHERE name = \"frontend_settings\";',\n        ).fetchone()\n\n        if frontend_settings is not None:\n            setting_value_map.update(json.loads(frontend_settings[0]))\n\n        cursor.execute(\n            'INSERT OR REPLACE INTO settings(name, value) VALUES(?, ?)',\n            ('frontend_settings', json.dumps(setting_value_map)),\n        )\n    # Delete the settings\n    cursor.execute(f'DELETE FROM settings WHERE name IN ({\",\".join(settings)});')\n    # Delete Bitfinex used_query_ranges\n    cursor.execute('DELETE FROM used_query_ranges WHERE name = \"bitfinex_trades\";')\n    # Delete Bitfinex trades\n    cursor.execute('DELETE FROM trades WHERE location = \"T\";')\n    # Delete deprecated historical data start setting\n    cursor.execute('DELETE from settings WHERE name=\"historical_data_start\";')\n    db.conn.commit()\n\n    # -- Now move forex history to the new directory and remove all old cache files\n    # We botched this. Should have been forex_history_file.json -> price_history_forex.json\n    # and not the other way around\n    data_directory = db.user_data_dir.parent\n    price_history_dir = get_or_make_price_history_dir(data_directory)\n    forex_history_file = data_directory / 'price_history_forex.json'\n    if forex_history_file.is_file():\n        shutil.move(\n            forex_history_file,  # type: ignore\n            price_history_dir / 'forex_history_file.json',\n        )\n\n    prefix = os.path.join(str(data_directory), 'price_history_')\n    prefix = prefix.replace('\\\\', '\\\\\\\\')\n    files_list = glob.glob(prefix + '*.json')\n    for file_ in files_list:\n        file_ = file_.replace('\\\\\\\\', '\\\\')\n        try:\n            Path(file_).unlink()\n        except OSError:\n            pass\n", "path": "rotkehlchen/db/upgrades/v22_v23.py"}]}