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

bulk create adds messages to db in wrong order #428

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

Conversation

mixmix
Copy link
Member

@mixmix mixmix commented Apr 11, 2024

Noticed that when adding lots of messages to the database quickly, they go in right,
but when you stream the out of the db, they come out with the wrong sequence order

This is a problem for legacy replication (createHistoryStream)

Copy link

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] None +7 950 kB architectci

🚮 Removed packages: npm/[email protected]

View full report↗︎


await Promise.all(
many.map((content) => {
return p(db.create)({ feedFormat: 'classic', content })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promise.all() is not the right way of doing this, you need to do them sequentially. Otherwise it's very likely indeed that they'll end up in the wrong order, because this has to do with jitdb indexing the log.

ssb-db2 is optimized for fast reads not for fast writes, so be patient if it's not the best at bulk creating msgs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote a test where I did it sequentially with a pull-stream, and it still got them wrong I think...

the fast writes thing is gonna be a challenge with Ahau importing some records. Working on that though

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

Successfully merging this pull request may close these issues.

2 participants