这是indexloc提供的服务,不要输入任何密码
Skip to content

SchemaDiff Tool hangs when attempting to compare Postgres Server and EDB Postgres Advanced Server #5952

@gregn123

Description

@gregn123

The SchemaDiff Tool includes checks to prevent database/schema comparison between Postgres Server and EDB Postgres Advanced Server. I find that recent versions of pgAdmin4 (6.16+) fail to report "Schema diff does not support the comparison between Postgres Server and EDB Postgres Advanced Server." because the code crashes out during the error handling, with an exception "TypeError: Object of type Response is not JSON serializable" (see Runtime log below, from pgAdmin4 6.19 running on Windows 10).
The end result is that all you see on screen is "Comparing Objects ... (this may take a few minutes)" and it never completes.
I created a patch for the pgAdmin4 6.21 code which seems to fix the issue (see attachment). Please review it.

pgAdmin Runtime Environment
--------------------------------------------------------
Python Path: "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\python.exe"
Runtime Config File: "C:\Users\Administrator\AppData\Roaming\pgadmin\runtime_config.json"
pgAdmin Config File: "C:\Program Files\PostgreSQL\15\pgAdmin 4\web\config.py"
Webapp Path: "C:\Program Files\PostgreSQL\15\pgAdmin 4\web\pgAdmin4.py"
pgAdmin Command: "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\python.exe -s C:\Program Files\PostgreSQL\15\pgAdmin 4\web\pgAdmin4.py"
Environment: 
  - ALLUSERSPROFILE: C:\ProgramData
  - APPDATA: C:\Users\Administrator\AppData\Roaming
  - CHROME_CRASHPAD_PIPE_NAME: \\.\pipe\crashpad_1060_BDISGPYWGJLDBYAV
  - CHROME_RESTART: NW.js|Whoa! NW.js has crashed. Relaunch now?|LEFT_TO_RIGHT
  - CommonProgramFiles: C:\Program Files\Common Files
  - CommonProgramFiles(x86): C:\Program Files (x86)\Common Files
  - CommonProgramW6432: C:\Program Files\Common Files
  - COMPUTERNAME: WIN-XXXXXXXXXXX
  - ComSpec: C:\Windows\system32\cmd.exe
  - DriverData: C:\Windows\System32\Drivers\DriverData
  - HOMEDRIVE: C:
  - HOMEPATH: \Users\Administrator
  - LOCALAPPDATA: C:\Users\Administrator\AppData\Local
  - LOGONSERVER: \\WIN-XXXXXXXXXXX
  - NUMBER_OF_PROCESSORS: 4
  - OS: Windows_NT
  - Path: C:\Tcl86\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\Git\cmd;C:\Program Files (x86)\Yarn\bin\;C:\Perl526\c\bin;C:\Perl526\perl\site\bin;C:\Perl526\perl\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools;C:\Users\Administrator\AppData\Roaming\npm;C:\Users\Administrator\AppData\Local\Yarn\bin
  - PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
  - PGADMIN_INT_KEY: 37521bd6-a90d-4589-a8ec-587e45619503
  - PGADMIN_INT_PORT: 55804
  - PGADMIN_SERVER_MODE: OFF
  - PROCESSOR_ARCHITECTURE: AMD64
  - PROCESSOR_IDENTIFIER: Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
  - PROCESSOR_LEVEL: 6
  - PROCESSOR_REVISION: 8e0a
  - ProgramData: C:\ProgramData
  - ProgramFiles: C:\Program Files
  - ProgramFiles(x86): C:\Program Files (x86)
  - ProgramW6432: C:\Program Files
  - PSModulePath: C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
  - PUBLIC: C:\Users\Public
  - SESSIONNAME: Console
  - SystemDrive: C:
  - SystemRoot: C:\Windows
  - TEMP: C:\Users\ADMINI~1\AppData\Local\Temp
  - TMP: C:\Users\ADMINI~1\AppData\Local\Temp
  - USERDOMAIN: WIN-XXXXXXXXXXX
  - USERDOMAIN_ROAMINGPROFILE: WIN-XXXXXXXXXXX
  - USERNAME: Administrator
  - USERPROFILE: C:\Users\Administrator
  - windir: C:\Windows
  - WIX: C:\Program Files (x86)\WiX Toolset v3.11\
--------------------------------------------------------

Total spawn time to start the pgAdmin4 server: 0.012 Sec
2023-03-14 17:19:05,005: WARNING	werkzeug:	WebSocket transport not available. Install simple-websocket for improved performance.

 * Serving Flask app 'pgadmin' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off

------------------------------------------
Total time taken to ping pgAdmin4 server: 7.218 Sec
------------------------------------------
Total launch time of pgAdmin4: 7.429 Sec
------------------------------------------
Application Server URL: http://127.0.0.1:55804/?key=37521bd6-a90d-4589-a8ec-587e45619503
The WebSocket transport is not available, you must install a WebSocket server that is compatible with your async mode to enable it. See the documentation for details. (further occurrences of this error will be logged with level INFO)

Exception in thread Thread-81 (_handle_event_internal):
Traceback (most recent call last):
  File "threading.py", line 1016, in _bootstrap_inner

  File "threading.py", line 953, in run
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\socketio\server.py", line 731, in _handle_event_internal
    r = server._trigger_event(data[0], namespace, sid, *data[1:])
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\socketio\server.py", line 756, in _trigger_event

    return self.handlers[namespace][event](*args)
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\flask_socketio\__init__.py", line 282, in _handler
    return self._handle_event(handler, message, namespace, sid,
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\flask_socketio\__init__.py", line 766, in _handle_event

    ret = handler(*args)
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\web\pgadmin\authenticate\__init__.py", line 68, in wrapped
    return f(*args, **kwargs)
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\web\pgadmin\tools\schema_diff\__init__.py", line 450, in compare_database
    socketio.emit('compare_database_failed', error_msg,
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\flask_socketio\__init__.py", line 460, in emit

    self.server.emit(event, *args, namespace=namespace, to=to,
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\socketio\server.py", line 319, in emit
    self.manager.emit(event, data, namespace, room=room,
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\socketio\base_manager.py", line 172, in emit
    self.server._emit_internal(eio_sid, event, data, namespace, id)
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\socketio\server.py", line 644, in _emit_internal
    self._send_packet(eio_sid, self.packet_class(
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\socketio\server.py", line 649, in _send_packet

    encoded_packet = pkt.encode()
  File "C:\Program Files\PostgreSQL\15\pgAdmin 4\python\lib\site-packages\socketio\packet.py", line 64, in encode
    encoded_packet += self.json.dumps(data, separators=(',', ':'))
  File "json\__init__.py", line 238, in dumps

  File "json\encoder.py", line 199, in encode
  File "json\encoder.py", line 257, in iterencode
  File "json\encoder.py", line 179, in default

TypeError: Object of type Response is not JSON serializable

fix_schemadiff_compare_pg_edb__pgAdmin4_621.patch

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions