pmwkaa / sophia

Modern transactional key-value/row storage library.
http://sophia.systems
Other
1.86k stars 155 forks source link

the "Create or open database after environment start" example does not work #113

Open brigadier opened 8 years ago

brigadier commented 8 years ago

The "Create or open database after environment start" example from the http://sphia.org/administration.html#database page does not work when DB already exists. First run - ok, DB gets autocreated; second run - error.

error: sophia/index/si_recover.c:610 directory './storage/test' already exists
pmwkaa commented 8 years ago

This is not a bug. Sophia shares a write-ahead log pool for all databases. Open an existing database during run means to reply existing log files. This only works during initial environment open.

Do you have a work case where you need this feature?

brigadier commented 8 years ago

After sp_destroy(db) was called, it is impossible to reopen db again with sp_open(db), the env should be closed and reopened with sp_destroy(env); sp_open(env); right?

pmwkaa commented 8 years ago

Yes, this is tricky. Database shutdown happens in background. Some explanations are available here: https://github.com/pmwkaa/sophia/issues/106

This probably will be fixed in future: database shutdown should wait sp_destroy(db) a. until all references are released (transactions, compaction, etc) b. all in-memory indexes flashed to disk.

If those two conditions are met, there would be no need to replay logs.

dumblob commented 5 years ago

@pmwkaa is the solution proposed by you being worked on or even already implemented?