File 0027-57199-revert-wip-65736-quincy.patch of Package ceph-ceph-17.2.9

diff --git a/src/common/options.h b/src/common/options.h
index ad39936d43a..e1d4ec16ed7 100644
--- a/src/common/options.h
+++ b/src/common/options.h
@@ -116,18 +116,6 @@ struct Option {
     }
   }
 
-  static level_t str_to_level(std::string_view s) {
-    if (s == "basic") {
-      return LEVEL_BASIC;
-    } else if (s == "advanced") {
-      return LEVEL_ADVANCED;
-    } else if (s == "dev") {
-      return LEVEL_DEV;
-    } else {
-      return LEVEL_UNKNOWN;
-    }
-  }
-
   enum flag_t {
     FLAG_RUNTIME = 0x1,         ///< option can be changed at runtime
     FLAG_NO_MON_UPDATE = 0x2,   ///< option cannot be changed via mon config
diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc
index 20234ec5768..084cf3ffc1e 100644
--- a/src/mgr/PyModule.cc
+++ b/src/mgr/PyModule.cc
@@ -609,13 +609,6 @@ int PyModule::load_options()
 	option.type = t;
       }
     }
-    p = PyDict_GetItemString(pOption, "level");
-    if (p && PyLong_Check(p)) {
-      long v = PyLong_AsLong(p);
-      option.level = static_cast<Option::level_t>(v);
-    } else {
-      option.level = Option::level_t::LEVEL_ADVANCED;
-    }
     p = PyDict_GetItemString(pOption, "desc");
     if (p && PyObject_TypeCheck(p, &PyUnicode_Type)) {
       option.desc = PyUnicode_AsUTF8(p);
diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc
index 7bc38131d58..4e9fa7d0232 100644
--- a/src/mon/MgrMonitor.cc
+++ b/src/mon/MgrMonitor.cc
@@ -1206,20 +1206,14 @@ bool MgrMonitor::prepare_command(MonOpRequestRef op)
         return r;
       }
       if (enable_down) {
-        bool has_active = !!pending_map.active_gid;
-        if (has_active && !mon.osdmon()->is_writeable()) {
+        if (!mon.osdmon()->is_writeable()) {
           mon.osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op));
           return false;
         }
         pending_map.flags |= MgrMap::FLAG_DOWN;
-        if (has_active) {
-          plugged |= drop_active();
-        }
+        plugged |= drop_active();
       } else {
         pending_map.flags &= ~(MgrMap::FLAG_DOWN);
-        if (pending_map.active_gid == 0) {
-          promote_standby();
-        }
       }
     } else {
       return -EINVAL;
diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py
index e90db88fd16..e4356175c6a 100644
--- a/src/pybind/mgr/devicehealth/module.py
+++ b/src/pybind/mgr/devicehealth/module.py
@@ -50,39 +50,31 @@ def get_nvme_wear_level(data: Dict[Any, Any]) -> Optional[float]:
 class Module(MgrModule):
 
     # latest (if db does not exist)
-    SCHEMA = [
-        """
-        CREATE TABLE Device (
-            devid TEXT PRIMARY KEY
-        ) WITHOUT ROWID;
-        """,
-        """
-        CREATE TABLE DeviceHealthMetrics (
-            time DATETIME DEFAULT (strftime('%s', 'now')),
-            devid TEXT NOT NULL REFERENCES Device (devid),
-            raw_smart TEXT NOT NULL,
-            PRIMARY KEY (time, devid)
-        );
-        """
-    ]
+    SCHEMA = """
+CREATE TABLE Device (
+  devid TEXT PRIMARY KEY
+) WITHOUT ROWID;
+CREATE TABLE DeviceHealthMetrics (
+  time DATETIME DEFAULT (strftime('%s', 'now')),
+  devid TEXT NOT NULL REFERENCES Device (devid),
+  raw_smart TEXT NOT NULL,
+  PRIMARY KEY (time, devid)
+);
+"""
 
     SCHEMA_VERSIONED = [
         # v1
-        [
-            """
-            CREATE TABLE Device (
-            devid TEXT PRIMARY KEY
-            ) WITHOUT ROWID;
-            """,
-            """
-            CREATE TABLE DeviceHealthMetrics (
-                time DATETIME DEFAULT (strftime('%s', 'now')),
-                devid TEXT NOT NULL REFERENCES Device (devid),
-                raw_smart TEXT NOT NULL,
-                PRIMARY KEY (time, devid)
-            );
-            """,
-        ]
+        """
+CREATE TABLE Device (
+  devid TEXT PRIMARY KEY
+) WITHOUT ROWID;
+CREATE TABLE DeviceHealthMetrics (
+  time DATETIME DEFAULT (strftime('%s', 'now')),
+  devid TEXT NOT NULL REFERENCES Device (devid),
+  raw_smart TEXT NOT NULL,
+  PRIMARY KEY (time, devid)
+);
+"""
     ]
 
     MODULE_OPTIONS = [
@@ -328,7 +320,6 @@ class Module(MgrModule):
 
         done = False
         with ioctx, self._db_lock, self.db:
-            self.db.execute('BEGIN;')
             count = 0
             for obj in ioctx.list_objects():
                 try:
@@ -521,7 +512,6 @@ class Module(MgrModule):
         """
 
         with self._db_lock, self.db:
-            self.db.execute('BEGIN;')
             self._create_device(devid)
             self.db.execute(SQL, (devid, json.dumps(data)))
             self._prune_device_metrics()
@@ -576,7 +566,6 @@ class Module(MgrModule):
         self.log.debug(f"_get_device_metrics: {devid} {sample} {min_sample}")
 
         with self._db_lock, self.db:
-            self.db.execute('BEGIN;')
             if isample:
                 cursor = self.db.execute(SQL_EXACT, (devid, isample))
             else:
diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py
index b8616119537..a12d3d448e8 100644
--- a/src/pybind/mgr/mgr_module.py
+++ b/src/pybind/mgr/mgr_module.py
@@ -18,7 +18,6 @@ import subprocess
 import threading
 from collections import defaultdict
 from enum import IntEnum, Enum
-import os
 import rados
 import re
 import socket
@@ -547,11 +546,6 @@ if TYPE_CHECKING:
 # common/options.h: value_t
 OptionValue = Optional[Union[bool, int, float, str]]
 
-class OptionLevel(IntEnum):
-    BASIC = 0
-    ADVANCED = 1
-    DEV = 2
-    UNKNOWN = 3
 
 class Option(Dict):
     """
@@ -562,7 +556,6 @@ class Option(Dict):
     def __init__(
             self,
             name: str,
-            level: OptionLevel = OptionLevel.ADVANCED,
             default: OptionValue = None,
             type: 'OptionTypeLabel' = 'str',
             desc: Optional[str] = None,
@@ -846,8 +839,6 @@ class MgrStandbyModule(ceph_module.BaseMgrStandbyModule, MgrModuleLoggingMixin):
                                  'warning', '']))
         cls.MODULE_OPTIONS.append(
             Option(name='log_to_file', type='bool', default=False, runtime=True))
-        cls.MODULE_OPTIONS.append(
-            Option(name='sqlite3_killpoint', level=OptionLevel.DEV, type='int', default=0, runtime=True))
         if not [x for x in cls.MODULE_OPTIONS if x['name'] == 'log_to_cluster']:
             cls.MODULE_OPTIONS.append(
                 Option(name='log_to_cluster', type='bool', default=False,
@@ -964,8 +955,8 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
     MODULE_OPTION_DEFAULTS = {}  # type: Dict[str, Any]
 
     # Database Schema
-    SCHEMA = None # type: Optional[List[str]]
-    SCHEMA_VERSIONED = None # type: Optional[List[List[str]]]
+    SCHEMA = None # type: Optional[str]
+    SCHEMA_VERSIONED = None # type: Optional[List[str]]
 
     # Priority definitions for perf counters
     PRIO_CRITICAL = 10
@@ -1050,8 +1041,6 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
                                  'warning', '']))
         cls.MODULE_OPTIONS.append(
             Option(name='log_to_file', type='bool', default=False, runtime=True))
-        cls.MODULE_OPTIONS.append(
-            Option(name='sqlite3_killpoint', level=OptionLevel.DEV, type='int', default=0, runtime=True))
         if not [x for x in cls.MODULE_OPTIONS if x['name'] == 'log_to_cluster']:
             cls.MODULE_OPTIONS.append(
                 Option(name='log_to_cluster', type='bool', default=False,
@@ -1151,20 +1140,15 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
             self.appify_pool(self.MGR_POOL_NAME, 'mgr')
 
     def create_skeleton_schema(self, db: sqlite3.Connection) -> None:
-        SQL = [
-        """
+        SQL = """
         CREATE TABLE IF NOT EXISTS MgrModuleKV (
           key TEXT PRIMARY KEY,
           value NOT NULL
         ) WITHOUT ROWID;
-        """,
-        """
         INSERT OR IGNORE INTO MgrModuleKV (key, value) VALUES ('__version', 0);
-        """,
-        ]
+        """
 
-        for sql in SQL:
-            db.execute(sql)
+        db.executescript(SQL)
 
     def update_schema_version(self, db: sqlite3.Connection, version: int) -> None:
         SQL = "UPDATE OR ROLLBACK MgrModuleKV SET value = ? WHERE key = '__version';"
@@ -1203,8 +1187,7 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
         if version <= 0:
             self.log.info(f"creating main.db for {self.module_name}")
             assert self.SCHEMA is not None
-            for sql in self.SCHEMA:
-                db.execute(sql)
+            db.executescript(self.SCHEMA)
             self.update_schema_version(db, 1)
         else:
             assert self.SCHEMA_VERSIONED is not None
@@ -1213,8 +1196,8 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
                 raise RuntimeError(f"main.db version is newer ({version}) than module ({latest})")
             for i in range(version, latest):
                 self.log.info(f"upgrading main.db for {self.module_name} from {i-1}:{i}")
-                for sql in self.SCHEMA_VERSIONED[i]:
-                    db.execute(sql)
+                SQL = self.SCHEMA_VERSIONED[i]
+                db.executescript(SQL)
             if version < latest:
                 self.update_schema_version(db, latest)
 
@@ -1223,21 +1206,13 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
         SELECT value FROM MgrModuleKV WHERE key = '__version';
         """
 
-        kv = self.get_module_option('sqlite3_killpoint')
         with db:
-            db.execute('BEGIN;')
             self.create_skeleton_schema(db)
-            if kv == 1:
-                os._exit(120)
             cur = db.execute(SQL)
             row = cur.fetchone()
             self.maybe_upgrade(db, int(row['value']))
             assert cur.fetchone() is None
             cur.close()
-            if kv == 2:
-                os._exit(120)
-        if kv == 3:
-            os._exit(120)
 
     def configure_db(self, db: sqlite3.Connection) -> None:
         db.execute('PRAGMA FOREIGN_KEYS = 1')
@@ -1261,10 +1236,7 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
             self.create_mgr_pool()
         uri = f"file:///{self.MGR_POOL_NAME}:{self.module_name}/main.db?vfs=ceph";
         self.log.debug(f"using uri {uri}")
-        try:
-            db = sqlite3.connect(uri, check_same_thread=False, uri=True, autocommit=False) # type: ignore[call-arg]
-        except TypeError:
-            db = sqlite3.connect(uri, check_same_thread=False, uri=True, isolation_level=None)
+        db = sqlite3.connect(uri, check_same_thread=False, uri=True)
         # if libcephsqlite reconnects, update the addrv for blocklist
         with db:
             cur = db.execute('SELECT json_extract(ceph_status(), "$.addr");')
openSUSE Build Service is sponsored by