For more readable code:
https://gist.github.com/corona10/d4fe0b6367ea6865e37b4369a7d60912

2022년 1월 21일 (금) 오후 12:50, Dong-hee Na <donghee...@python.org>님이 작성:

> I exchanged a mail for investigating details.
>
> Before getting started, please remind the following fact.
> - The latest snapshot is always valid, even if corruption has not occurred.
>
> > Why is a separated script needed? / A single script cannot automatically
> detect a corrupted database and load the latest snapshot?
>
> So, the author said a separate script is never needed,
> if the user reads from the latest snapshot file, it will always be
> recovered.
> so the user code will be like this.
>
> import dbm.gnu as dbm
>
> # skip check code that all files are exists, origin, even_snapshot, 
> odd_snapshot
>
>
> if origin is None:
>
>     db = dbm.open(origin, 'nx') # For extension format
>
>     db.gdbm_failure_atomic(even_snapshot, odd_snapshot) # For snapshot 
> declaration
>
> else:
>
>     latest_snapshot = dbm.gdbm_latest_snapshot(even_snapshot odd_snapshot)
>
>           db = dbm.open(latest_snapshot, 'r') # Open the latest valid snapshot
>
> for k, v in zip('abcdef', 'ghijkl'):
>     db[k] = v
>
> db.sync()
> db.close()
>
>
> > How is different from simply copying the whole database file?
>
>
> Under the hood, the gdbm crash-tolerance mechanism *does* (logically) copy
> the whole database file, but it does so efficiently, using "reflink"
> copies, so the amount of physical storage resources used is minimal.
>
> You may good to read this paper: 
> https://dl.acm.org/doi/pdf/10.1145/3487019.3487353
>
>
> Warm Regards,
>
> Dong-hee
>
>
> 2022년 1월 18일 (화) 오후 10:54, Victor Stinner <vstin...@python.org>님이 작성:
>
>> How does someone know if a database is corrupted? Why is a separated
>> script needed?
>>
>> A single script cannot automatically detect a corrupted database and
>> load the latest snapshot?
>>
>> How is different from simply copying the whole database file?
>>
>> Victor
>> --
>> Night gathers, and now my watch begins. It shall not end until my death.
>>
>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/SQVHJIMKH4GDACFWUVSY35ZVVKND6R2S/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to