public inbox for [email protected]
help / color / mirror / Atom feedFrom: Bradford Boyle <[email protected]>
To: [email protected]
Subject: omnidb-server: fix for bug 1053100
Date: Wed, 19 Jun 2024 23:50:08 -0700
Message-ID: <CAOMoQbTE3MUJHZh3HkbwkkGbeEBy37AMAQwZUPr7atvmMZyXMw@mail.gmail.com> (raw)
Hi All,
I have been looking at Debian bug 1053100 (omnidb-server crashes when
creating a new PostgreSQL connection) [1] and I have identified that
this is caused by a change in one of OmniDB's Python dependencies.
OmniDB configures Django's session serialization format to use Python's
`pickle` module instead of the default JSON-based serialization. The
class `Session` has a field `v_databases` that is a dictionary tha
contains references to objects holding information for the various
connections the user has configured. When a connection to a PostgreSQL
database is configured, the `Session` object ends up transitively
referencing an instance of `PGSpecial` from provided by the Python
package `pgspecial`. A recent change in `pgspecial` means that
`PGSpecial` objects are no longer serializable with Python's `pickle`
module.
Reviewing OmniDB's use of `PGSpecial` within its `PostgreSQL` class, it
appears to be a "stateless" in that it does not use the `PGSpecial`
object in any way that would cause its fields to be change value from
when it was constructed. Based on this observation, an approach to
fixing the reported bug is to patch OmniDB's `PostgreSQL` class to omit
`PGSpecial` during serialization and to recreate it during
deserialization. I have a attached a patch that will do this. In my
limited local testing, this fixes the bug. If there are no concerns with
the proposed patch, I can update the package on s.d.o.
It looks like Django 5.x has deprecated `PickleSerializer` [2] so its
unlikely that OmniDB will continue working going forward. At the moment,
Debian testing still provides Django 4.2 but I do not know if the Debian
Python team has plans to update to the newer major version. Independent
of the Django major version incompatibility, it looks like the upstream
repo for OmniDB has gone inactive and the project is unmaintained [3].
Does it make sense to continue publishing packages of OmniDB for newer
releases of Debian and Ubuntu?
-- Bradford
[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053100
[2]: https://github.com/django/django/pull/15139
[3]: https://github.com/OmniDB/OmniDB
Attachments:
[application/octet-stream] 0001-Customize-PostgreSQL-class-pickle-serialization.patch (1.8K, 2-0001-Customize-PostgreSQL-class-pickle-serialization.patch)
download | inline diff:
From 6a46c1068bf90faaf3b73024e8c48b04899a8e97 Mon Sep 17 00:00:00 2001
From: "Bradford D. Boyle" <[email protected]>
Date: Sun, 12 May 2024 20:39:07 -0700
Subject: [PATCH] Customize PostgreSQL class pickle serialization
This commit modifies PostgreSQL to omit v_special when pickling. OmniDB
is configured to use django's PickleSerializer but Python's pickle
module can only serialize functions that are accessible from the
top-level of a module. Newer version's of pgspecial use an inner
function when creating SpecialCommands. This causes an AttributeError to
be thrown with the following message:
AttributeError: Can't pickle local object
'show_extra_help_command.<locals>.placeholder'
When an instance of PostgreSQL is deserialized, v_special is recreated.
This approach works since v_special is only read and isn't modified.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053100
https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled
---
OmniDB/OmniDB_app/include/Spartacus/Database.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/OmniDB/OmniDB_app/include/Spartacus/Database.py b/OmniDB/OmniDB_app/include/Spartacus/Database.py
index a41281bc..4ec25a08 100644
--- a/OmniDB/OmniDB_app/include/Spartacus/Database.py
+++ b/OmniDB/OmniDB_app/include/Spartacus/Database.py
@@ -1859,6 +1859,16 @@ class PostgreSQL(Generic):
if not v_keep:
self.Close()
+ def __getstate__(self):
+ state = self.__dict__.copy()
+ # don't pickle 'v_special'
+ del state["v_special"]
+ return state
+
+ def __setstate__(self, state):
+ self.__dict__.update(state)
+ # add 'v_special' back since it doesn't exist in the pickle
+ self.v_special = PGSpecial()
'''
------------------------------------------------------------------------
--
2.45.2
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: omnidb-server: fix for bug 1053100
In-Reply-To: <CAOMoQbTE3MUJHZh3HkbwkkGbeEBy37AMAQwZUPr7atvmMZyXMw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox