{"id":24973272,"url":"https://github.com/bluedynamics/relstorage_packer","last_synced_at":"2025-04-11T08:13:16.858Z","repository":{"id":11761849,"uuid":"14295841","full_name":"bluedynamics/relstorage_packer","owner":"bluedynamics","description":"Packs a Zope ZODB in a history free PostgreSQL RelStorage with blobs in filesystem - fast.","archived":false,"fork":false,"pushed_at":"2024-04-02T15:38:07.000Z","size":476,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-25T05:41:42.083Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/relstorage_packer","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bluedynamics.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE.rst","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-11T08:56:03.000Z","updated_at":"2014-09-05T09:31:08.000Z","dependencies_parsed_at":"2022-09-01T12:11:31.015Z","dependency_job_id":null,"html_url":"https://github.com/bluedynamics/relstorage_packer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluedynamics%2Frelstorage_packer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluedynamics%2Frelstorage_packer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluedynamics%2Frelstorage_packer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluedynamics%2Frelstorage_packer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluedynamics","download_url":"https://codeload.github.com/bluedynamics/relstorage_packer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248182096,"owners_count":21060893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-03T18:27:01.433Z","updated_at":"2025-04-11T08:13:16.841Z","avatar_url":"https://github.com/bluedynamics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"relstorage_packer\n=================\n\nPacks a ZODB in a *history-free* PostgreSQL RelStorage with blobs in\nfilesystem.\n\n\nOverview\n--------\n\nThis script works also for very large Relstorage ZODBs with several million\nobjects. The original pack script took several days and consumed lots of RAM.\nSo there was need to accelerate the process of packing.\n\nThis script does not consume relevant amounts of RAM, runs much faster than the\noriginal. Where the old took 3.5 days only for analysis it takes now about 6\nhours. On subsequent runs it only processes changes after last run: it\nconsiders only transactions newer than last processed transaction of the prior\nrun.\n\nAt time of writing processing 44mio objects takes initially about 3-6h\ndepending on hardware and configuration of Postgresql.\n\nThe script creates an inverse object graph, this takes little extra space in DB.\n\n\nLimitations\n-----------\n\nAt time of development the critical production environment was a postgresql\ndatabase running relstorage with blobs stored on a fileserver in history free\nmode. So this is implemented.\n\nI'am sure its easily possible to make this work on MySQL and Oracle too.\nAlso considering blobs inside DB is for sure possible.\n\nI'am not sure if this way of cleanup makes sense for non-history-free mode. At\nleast it needs a lot of love and understanding of ZODB to refactor and\nimplement.\n\nContributions are welcome!\n\n\nUsage\n-----\n\nCreate a configuration file. It is the same as used in classical pack script\ndeployed with Relstorage::\n\n    \u003crelstorage\u003e\n        create-schema false\n        keep-history false\n        shared-blob-dir true\n        blob-dir var/blobstorage\n        commit-lock-timeout 600\n        \u003cpostgresql\u003e\n            dsn dbname='test_site' host='127.0.0.1' user='zodb' password='secret'\n        \u003c/postgresql\u003e\n    \u003c/relstorage\u003e\n\nAfter installation a script ``relstorage_pack`` is available::\n\n    Usage: relstorage_pack config_file\n\n    Fast ZODB Relstorage Packer for history free PostgreSQL\n    \n    Options:\n      -h, --help     show this help message and exit\n      -i, --init     Removes all reference counts and starts from scratch.\n      -v, --verbose  More verbose output, includes debug messages.\n\nWhen running first time with your database pass ``--init`` as parameter. This\ndrops and recreates the packing table.\n\n\nHow it works\n============\n\nAt first run it creates a table ``object_inrefs`` used for inverse reference\ncounting. The table has:\n\n``zoid BIGINT NOT NULL,``\n    this is the object id where incoming references are counted  for\n\n``tid BIGINT NOT NULL CHECK (tid \u003e 0)``\n    transaction id of the zoid\n\n``inref BIGINT,``\n    the object id of the incoming reference OR\n    the same as zoid.\n\n``numinrefs BIGINT NOT NULL DEFAULT 0,``\n    if zoid==inref this is the counter field, otherwise it is not relevant.\n\nSo this table is used for two different things:\n\n1) keeping track of the incoming references\n\n2) counting the incoming references.\n\nThe code runs in three main phases:\n\ninitial preparation phase\n    creates missing tables, cleans object_inrefs table and runs through all\n    transactions in order to count and record all transactions.\n\nsubsequent runs preparation phase\n    1) starts at last know tid and then runs through all new\n       transactions in order to count and record changes of new transactions.\n    2) for each new transaction zoid (current) check also if there where\n       references gone meanwhile. so get all prior filed references of current\n       and remove any not valid anymore. For each removed decrement the counter\n       on ``object_inrefs`` where zoid=reference and inref=reference.\n\ncleanup phase\n    1) select an orphan, a zoid with no incoming refs\n    2) get all zoids referenced by this orphan\n    3) for each of this reference delete the entry from ``object_inrefs`` where\n       inref=orphan and zoid=reference\n    4) decrement counter on the entry where zoid=reference and inref=reference\n    5) delete the entry with the orphaned zoid from ``object_state`` (real data)\n    6) start with (1) unless theres no orphan any more.\n\n\nSource Code\n===========\n\nThe sources are in a GIT DVCS with its main branches at\n`github \u003chttp://github.com/bluedynamics/relstorage_packer\u003e`_.\n\nWe'd be happy to see many forks and pull-requests to make this package even\nbetter.\n\nUsing integrated buildout and testing\n-------------------------------------\n\nTesting this code i not easy and writing good tests is a task to be done.\nAt the moment you can try the code bu running a\npostgres database on localhost (unless you want to change ``buildout.cfg``).\nThen run as database-user (named ``postgres`` on debian) the commands::\n\n    psql -c \"CREATE USER zope WITH PASSWORD 'secret';\"\n    psql -c \"CREATE DATABASE relstorage_packer_test OWNER zope;\"\n    psql -c \"REVOKE connect ON DATABASE relstorage_packer_test FROM PUBLIC;\"\n    psql -c \"GRANT connect ON DATABASE relstorage_packer_test TO zope;\"\n \nNext (because of my laziness) run ``./bin/instance start`` which starts a Plone.\nAdd a Plone Site, add and delete some content to fill the database with\nsomething to pack.\n\nNext run the packer.\n\nIf you dont like this: pull requests are always welcome.\n\nContributors\n============\n\n- Jens W. Klein \u003cjens@bluedynamics.com\u003e (Maintainer)\n\nThanks to Robert Penz for some good ideas at our Linux User Group Tirol Meeting.\nAlso thanks to Shane Hathaway for ``Relstorage`` and Jim Fulton for ZODB and\n``zc.zodbdgc`` (which unfortunately does not work with Relstorage).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluedynamics%2Frelstorage_packer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluedynamics%2Frelstorage_packer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluedynamics%2Frelstorage_packer/lists"}