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

Add support for loadBeforeEx #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

navytux
Copy link
Contributor

@navytux navytux commented Nov 11, 2021

zc.zlibstorage wraps base storage and includes generic getattr
to forward all unknown attribute access to base:

https://github.com/zopefoundation/zc.zlibstorage/blob/6d5a3c75/src/zc/zlibstorage/__init__.py#L52-L53

But if base implements loadBeforeEx (zopefoundation/ZODB#323)
the following scenario is then possible:

ZODB sees that zlibstorage provides loadBeforeEx and loads data via
loadBeforeEx instead of loadBefore, but the data are loaded
not decompressed, and ZODB complains about "broken pickle".

-> let's fix this by explicitly wrapping loadBeforeEx if base storage
provides it.

navytux added a commit to navytux/relstorage that referenced this pull request Nov 11, 2021
loadBeforeEx is like loadBefore, but simpler, provides better
information for object delete records and can be more efficiently
implemented by many storages: zopefoundation/ZODB#323

On RelStorage loadBefore is currently implemented via 3 SQL queries:

  1) check whether object record exists at all
  2) retrieve object state
  3) retrieve serial of next object revision

Compared to that loadBeforeEx is implemented via only one SQL query "2"
from the above - "retrieve object state". It is exactly the same query
that loadBefore uses and after the patch loadBefore actually invokes
loadBeforeEx for step 2.

This change was outlined in

zopefoundation/ZODB#318 (comment) and
zopefoundation/ZODB#318 (comment)

and as explained in the first link this patch is also semantically coupled with

zodb#484

This patch passes tests with both ZODB5 and with ZODB5+zopefoundation/ZODB#323:

- when ran with ZODB5 it verifies that loadBefore implementation does
  not become broken.

- when ran with ZODB5+zopefoundation/ZODB#323 it
  verifies that loadBeforeEx implementation is correct.

For tests to pass with
ZODB5+zopefoundation/ZODB#323 we also need
zopefoundation/zc.zlibstorage#11 because without
that fix zc.zlibstorage does not decompress data on loadBeforeEx.
@icemac
Copy link
Member

icemac commented Nov 16, 2021

Could you please rebase on master, so the tests run?

zc.zlibstorage wraps base storage and includes generic __getattr__
to forward all unknown attribute access to base:

https://github.com/zopefoundation/zc.zlibstorage/blob/6d5a3c75/src/zc/zlibstorage/__init__.py#L52-L53

But if base implements loadBeforeEx (zopefoundation/ZODB#323)
the following scenario is then possible:

ZODB sees that zlibstorage provides loadBeforeEx and loads data via
loadBeforeEx instead of loadBefore, but the data are loaded
not decompressed, and ZODB complains about "broken pickle".

-> let's fix this by explicitly wrapping loadBeforeEx if base storage
provides it.
@navytux
Copy link
Contributor Author

navytux commented Nov 16, 2021

Yes, sure, rebased.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1465884568

  • 2 of 7 (28.57%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-2.5%) to 96.226%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/zc/zlibstorage/init.py 2 7 28.57%
Totals Coverage Status
Change from base Build 1465851117: -2.5%
Covered Lines: 261
Relevant Lines: 268

💛 - Coveralls

@icemac
Copy link
Member

icemac commented Oct 25, 2022

Are there any news for this PR, is it valid or should it be closed?

@navytux
Copy link
Contributor Author

navytux commented Nov 1, 2022

@icemac, thanks for pinging and I appologize for the delay with replying on my side.

This PR is valid but it also depends on zopefoundation/ZODB#323. It should not be merged before zopefoundation/ZODB#323 is merged.

@icemac icemac added the do not (yet) merge PR is not (yet) ready to be merged label Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not (yet) merge PR is not (yet) ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants