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

redis has changed their lock API in a backwards incompatible fashion #220

Closed
rsgmon opened this issue Jun 8, 2022 · 11 comments
Closed

redis has changed their lock API in a backwards incompatible fashion #220

rsgmon opened this issue Jun 8, 2022 · 11 comments
Labels
bug Something isn't working redis

Comments

@rsgmon
Copy link

rsgmon commented Jun 8, 2022

I'm using the Redis backend and basically copied the code from the module in sqlalchemy that contains the CachingQuery class. However I am using manual keys.

With the following configuration I get the intermittent error in subject line.

regions["default"] = make_region(key_mangler=md5_key_mangler).configure( "dogpile.cache.redis", expiration_time=3600, arguments={ "host": config["redis"].get("host"), "redis_expiration_time": 60 * 60 * 2, "distributed_lock": True, "thread_local_lock": False, }, )

Here's the code where it occurs:

`

    _async = False
    if self._has_value(createdtime):

        has_value = True

    -->   if not self.mutex.acquire(False):

            log.debug("creation function in progress elsewhere, returning")

            return NOT_REGENERATED

    else:

        has_value = False

        log.debug("no value, waiting for create lock")`

Any suggestions would be appreciated.

@zzzeek
Copy link
Member

zzzeek commented Jun 8, 2022

I would need to see a complete stack trace

@rsgmon
Copy link
Author

rsgmon commented Jun 8, 2022

`File "foundation/list/mixins.py", line 60, in get_state_list_item_by_name
  .filter(ListItem.name == state_list_item_name)

File "sqlalchemy/orm/query.py", line 2979, in first
  ret = list(self[0:1])

File "sqlalchemy/orm/query.py", line 2771, in __getitem__
  return list(res)

File "foundation/caching_query.py", line 64, in __iter__
  return self.get_value(createfunc=lambda: list(super_.__iter__()))

File "foundation/caching_query.py", line 138, in get_value
  cache_key, createfunc, expiration_time=expiration_time

File "dogpile/cache/region.py", line 1047, in get_or_create
  async_creator,

File "dogpile/lock.py", line 185, in __enter__
  return self._enter()

File "dogpile/lock.py", line 94, in _enter
  generated = self._enter_create(value, createdtime)

File "dogpile/lock.py", line 126, in _enter_create
  if not self.mutex.acquire(False):`

@zzzeek zzzeek changed the title TypeError dogpile.lock in _enter_create, acquire() takes 1 positional argument but 2 were given redis has changed their lock API in a backwards incompatible fashion Jun 8, 2022
@zzzeek zzzeek added bug Something isn't working redis labels Jun 8, 2022
@zzzeek
Copy link
Member

zzzeek commented Jun 8, 2022

redis has been releasing in recent weeks and they changed this API to be positional only (even though I think main Python API is positional only, will check)

@sqla-tester
Copy link
Collaborator

Mike Bayer has proposed a fix for this issue in the main branch:

repair backwards incompat redis lock changes https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/3904

@zzzeek
Copy link
Member

zzzeek commented Jun 8, 2022

they changed the API in release 4.3.2

redis/redis-py@fa0be76#r75610569

@jvanasco
Copy link
Member

jvanasco commented Jun 8, 2022

FYI, It looks like Redis took over that project from https://github.com/andymccurdy sometime in the past 2 years. The original maintainer was often focused on API stability.

@CaselIT
Copy link
Member

CaselIT commented Jun 8, 2022

Seems to be fixed in 4.3.3 redis/redis-py#2209 (comment)

@zzzeek
Copy link
Member

zzzeek commented Jun 8, 2022

yeah....OK let me just run dogpile main in jenkins and we can close this

@zzzeek
Copy link
Member

zzzeek commented Jun 8, 2022

it's still wrong

@zzzeek
Copy link
Member

zzzeek commented Jun 8, 2022

redis/redis-py#2223

submitter please pin to py-redis 4.3.1 until they fix this

@rsgmon
Copy link
Author

rsgmon commented Jun 8, 2022

ok thanks, updated to "redis==4.3.1",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working redis
Projects
None yet
Development

No branches or pull requests

5 participants