Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'UnixDomainSocketConnection' object has no attribute '_command_packer' #2581

Closed
TheUbuntuGuy opened this issue Feb 7, 2023 · 8 comments
Closed

Comments

@TheUbuntuGuy
Copy link

Version: v4.5.0

Platform: Debian Bullseye using Python v3.9.2

Description:
The following code which used to work on up to and including v4.4.2 now crashes with the stack trace below on v4.5.0.

redis_conn = redis.Redis(
        unix_socket_path="/var/run/redis/redis-server.sock",
        decode_responses=True)
redis_conn.ping()
Traceback (most recent call last):
  File "<redacted>", line 142, in main
    redis_conn.ping()
  File "/usr/local/lib/python3.9/dist-packages/redis/commands/core.py", line 1194, in ping
    return self.execute_command("PING", **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/redis/client.py", line 1258, in execute_command
    return conn.retry.call_with_retry(
  File "/usr/local/lib/python3.9/dist-packages/redis/retry.py", line 46, in call_with_retry
    return do()
  File "/usr/local/lib/python3.9/dist-packages/redis/client.py", line 1259, in <lambda>
    lambda: self._send_command_parse_response(
  File "/usr/local/lib/python3.9/dist-packages/redis/client.py", line 1234, in _send_command_parse_response
    conn.send_command(*args)
  File "/usr/local/lib/python3.9/dist-packages/redis/connection.py", line 916, in send_command
    self._command_packer.pack(*args),
AttributeError: 'UnixDomainSocketConnection' object has no attribute '_command_packer'
@alee
Copy link

alee commented Feb 7, 2023

also seeing this in our apps, had to pin to 4.4.2 to prevent our django app from crashing anytime it attempted to use the cache

@woutdenolf
Copy link
Contributor

woutdenolf commented Feb 7, 2023

I guess this is the issue:

class Connection:
    def __init__(self, ...):
        ...
        self._command_packer = self._construct_command_packer(command_packer)

class SSLConnection(Connection):
    def __init__(self, ...):
        ...
        super().__init__(...)

class UnixDomainSocketConnection(Connection):
    def __init__(self, ...):
         # does not call _construct_command_packer nor super().__init__()

@woutdenolf
Copy link
Contributor

woutdenolf commented Feb 7, 2023

Seems like the bug was introduced just before the 4.5.0 release: #2570

@prokazov Could you take a look please?

Strange that this does not get picked up by the tests.

@prokazov
Copy link
Contributor

prokazov commented Feb 7, 2023

Looks like there is no synchronous tests that run any command on SSLConnection/UnixDomainSocketConnection.

@woutdenolf
Copy link
Contributor

Actually SSLConnection does call super().__init__ so that one should be fine.

@woutdenolf
Copy link
Contributor

woutdenolf commented Feb 7, 2023

The fact that UnixDomainSocketConnection.__init__ does not call super().__init__ is probably worth fixing. I see lots of copy&paste so seems doable? Perhaps introduce an AbstractConnection with abstract methods _connect, repr_pieces and _error_message?

@woutdenolf
Copy link
Contributor

woutdenolf commented Feb 7, 2023

Connection has host and port while UnixDomainSocketConnection has path.

Connection has in addition socket_connect_timeout, socket_keepalive , socket_keepalive_options and socket_type.

Lastly there is if retry or retry_on_error: vs. if retry_on_error:. This discrepancy is probably also a mistake #2377 @barshaul ?

The rest is identical.

prokazov added a commit to prokazov/redis-py that referenced this issue Feb 7, 2023
…command_packer' .

Apparently there is no end-to-end tests for Unix sockets
 so automation didn't catch it.  I assume that setting up
domain sockets reliably  in dockerized environment is not
very trivial.
Added test for pack_command specifically.
@prokazov
Copy link
Contributor

prokazov commented Feb 8, 2023

@woutdenolf @TheUbuntuGuy @chayim @dvora-h
Here is the fix, please review it:
#2583

@chayim @dvora-h
I tried to add a full end-to-end Unix socket test but it took a little bit too much time so I felt back to a unit one.
Last thing I tried was something like:
touch /tmp/redis.sock and add it to volumes in tox.ini[master], which still resulted to "connection refused" ("docker exec -it master ls /tmp/" confirmed the presence of this file in the container) and I gave up.

@dvora-h dvora-h closed this as completed in 2b470cb Feb 8, 2023
bors-ltd added a commit to openmaraude/APITaxi that referenced this issue Feb 8, 2023
chayim pushed a commit that referenced this issue Aug 31, 2023
Co-authored-by: Viktor Ivanov <viktor@infogrid.io>
Co-authored-by: Sergey Prokazov <sergey.prokazov@redis.com>
Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com>
Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
Co-authored-by: Alex Schmitz <aschmitz@box.com>
Co-authored-by: Alex Schmitz <alex.schmitz@gmail.com>
Co-authored-by: Chayim <chayim@users.noreply.github.com>
Co-authored-by: Bar Shaul <88437685+barshaul@users.noreply.github.com>
Co-authored-by: CrimsonGlory <CrimsonGlory@users.noreply.github.com>
Co-authored-by: Raymond Yin <raymond@tryevergreen.com>
Co-authored-by: zach.lee <zach.lee@sendbird.com>
Co-authored-by: James R T <jamestiotio@gmail.com>
Co-authored-by: dvora-h <dvora.heller@redis.com>
Co-authored-by: Marc Schöchlin <marc.schoechlin@flipapp.de>
Co-authored-by: Nick Gerow <nick.gerow@enlightedinc.com>
Co-authored-by: Igor Malinovskiy <u.glide@gmail.com>
Co-authored-by: Chayim I. Kirshen <c@kirshen.com>
Co-authored-by: Leibale Eidelman <me@leibale.com>
Co-authored-by: Thiago Bellini Ribeiro <hackedbellini@gmail.com>
Co-authored-by: woutdenolf <woutdenolf@users.sf.net>
Co-authored-by: shacharPash <93581407+shacharPash@users.noreply.github.com>
Co-authored-by: Mirek Długosz <miniopl+github@gmail.com>
Co-authored-by: Oran Avraham <252748+oranav@users.noreply.github.com>
Co-authored-by: mzdehbashi-github <85902780+mzdehbashi-github@users.noreply.github.com>
Co-authored-by: Tyler Hutcherson <tyler.hutcherson@redis.com>
Co-authored-by: Felipe Machado <462154+felipou@users.noreply.github.com>
Co-authored-by: AYMEN Mohammed <53928879+AYMENJD@users.noreply.github.com>
Co-authored-by: Marc Schöchlin <ms-github@256bit.org>
Co-authored-by: Avasam <samuel.06@hotmail.com>
Co-authored-by: Markus Gerstel <2102431+Anthchirp@users.noreply.github.com>
Co-authored-by: Kristján Valur Jónsson <sweskman@gmail.com>
Co-authored-by: Nick Gerow <Nick.G.123@hotmail.com>
Co-authored-by: Cristian Matache <cristianmatache@hotmail.com>
Co-authored-by: Anurag Bandyopadhyay <angbpy@gmail.com>
Co-authored-by: Seongchuel Ahn <aciddust20@gmail.com>
Co-authored-by: Alibi <aliby.bbb@gmail.com>
Co-authored-by: Smit Parmar <smitraj333@gmail.com>
Co-authored-by: Brad MacPhee <macphee@gmail.com>
Co-authored-by: Shahar Lev <shahar_lev@hotmail.com>
Co-authored-by: Vladimir Mihailenco <vladimir.webdev@gmail.com>
Co-authored-by: Kevin James <KevinJames@thekev.in>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Pacsuta <34983281+ant1fact@users.noreply.github.com>
Co-authored-by: Rich Bowen <rbowen@rcbowen.com>
Co-authored-by: gmbnomis <gmbnomis@users.noreply.github.com>
Co-authored-by: Vivanov98 <66319645+Vivanov98@users.noreply.github.com>
Co-authored-by: Kosuke <kosuke.zhang@gmail.com>
Co-authored-by: Sergey Prokazov <prokazov@users.noreply.github.com>
Co-authored-by: jmcbailey <jmcbailey@gmail.com>
Co-authored-by: Galtozzy <14139502+Galtozzy@users.noreply.github.com>
Co-authored-by: Abhishek Kumar Sinha <aksinha334@gmail.com>
Co-authored-by: Eom Taegyung "Iggy <iggy.eom@sendbird.com>
Co-authored-by: Mehdi ABAAKOUK <sileht@sileht.net>
Co-authored-by: Dongkeun Lee <3315213+zakaf@users.noreply.github.com>
Co-authored-by: woutdenolf <wout.de_nolf@esrf.eu>
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
Co-authored-by: Juraj Páll <palljuraj1@gmail.com>
Co-authored-by: Joan Fontanals <jfontanalsmartinez@gmail.com>
Co-authored-by: Stanislav Zmiev <zmievsa@gmail.com>
fix (#2566)
Fix unlink in cluster pipeline (#2562)
Fix issue 2540: Synchronise concurrent command calls to single-client mode. (#2568)
Fix: tuple function cannot be passed more than one argument (#2573)
Fix issue 2567: NoneType check before raising exception (#2569)
Fix issue 2349: Let async HiredisParser finish parsing after a Connection.disconnect() (#2557)
Fix issue with `pack_commands` returning an empty byte sequence (#2416)
Fix #2581 UnixDomainSocketConnection' object has no attribute '_command_packer' (#2583)
Fix #2581 UnixDomainSocketConnection' object has no attribute '_command_packer' .
Fix for `lpop` and `rpop` return typing (#2590)
Fixed CredentialsProvider examples (#2587)
Fixed issue #2598 - make Document class subscriptable
fix: replace async_timeout by asyncio.timeout (#2602)
Fix behaviour of async PythonParser to match RedisParser as for issue #2349 (#2582)
Fix (#2641)
fix: do not use asyncio's timeout lib before 3.11.2 (#2659)
Fix issue 2660: PytestUnraisableExceptionWarning from asycio client (#2669)
Fixing cancelled async futures (#2666)
Fix async (#2673)
Fix memory leak caused by hiredis (#2693) (#2694)
Fix incorrect usage of once flag in async Sentinel (#2718)
Fix topk list example. (#2724)
Fix `ClusterCommandProtocol` not itself being marked as a protocol (#2729)
Fix potential race condition during disconnection (#2719)
fix CI (#2748)
fix parse_slowlog_get (#2732)
fixes for issue #1128
fix create single_connection_client from url (#2752)
Fix `xadd` allow non negative maxlen (#2739)
Fix JSON.MERGE Summary (#2786)
Fixed key error in parse_xinfo_stream (#2788)
Fix dead weakref in sentinel connection causing ReferenceError (#2767) (#2771)
Fix dead weakref in sentinel conn (#2767)
fix redirects and some small cleanups (#2801)
Fix type hint for retry_on_error in async cluster (#2804)
Fix CI (#2809)
Fix async client with resp3 (#2657)
Fix `COMMAND` response in resp3 (redis 7+) (#2740)
Fix protocol version checking (#2737)
Fix parse resp3 dict response: don't use dict comprehension (#2757)
Fixing asyncio import (#2759)
fix (#2799)
fix async tests (#2806)
Fix socket garbage collection (#2859)
Fixing doc builds (#2869)
Fix a duplicate word in `CONTRIBUTING.md` (#2848)
Fix timeout retrying on Redis pipeline execution (#2812)
Fix type hints in SearchCommands (#2817)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants