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

Sporadic Fetch Failures (Multi-Process Support ?) #72

Open
movitto opened this issue Jun 6, 2019 · 3 comments
Open

Sporadic Fetch Failures (Multi-Process Support ?) #72

movitto opened this issue Jun 6, 2019 · 3 comments

Comments

@movitto
Copy link
Contributor

movitto commented Jun 6, 2019

Greetings! I've been exploring & diving into this library into the context of reading data directly from a live rippled nodestore. Periodically a fetch operation will sporadically fail with the 'key_not_found' error. Subsequently trying to fetch the same key using a new database connection succeeds. I'm 100% sure the values exist in the DB before starting this process.

After exploring the code my primary thought as to the cause of this is a race condition, where the rippled process is flushing data to the nodestore file just as I'm trying to read the bucket containing the data. This could result in a lookup failure, though admittedly I haven't been able to pinpoint this as being the exact cause. Subsequent lookups of the same key using the same database connection fail until it is closed / reopened, leading me to believe internal in-memory cache buckets are getting out of sync (or similar). Does this sound like it could be the cause of this issue or if not any idea on what could be the problem?

If this is the issue, care would need to be taken to support multi-process access for this to be resolved. Sqlite3 employs on-disk locking solutions to facilitate this, but even there that is less than ideal. Would there be any interest in adding something similar to this library? For the time being, we can live with closing/reopening the db on failure, but it'd be nice to utilize something more robust!

Appreciate any insights.

@vinniefalco
Copy link
Member

Hmm... nudb assumes that it has exclusive access to the file. Accessing any of the database files from more than one process at the same time, or from two separate instances of store in the same process, results in undefined behavior.

@movitto
Copy link
Contributor Author

movitto commented Jun 6, 2019

Gotchya, thanks for the info @vinniefalco. I figured such as I didn't see anything in the code that would sanitize multi-process access. I'll look into how sqlite3 implements this internally and perhaps if something similar could be implemented in NuDB.

@vinniefalco
Copy link
Member

The most sane way to do it would be to modify rippled and use the existing instance of the nudb::store to perform your fetches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants