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

add ordering notes #40

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,34 @@ You will find information on the repair operation in the `LOG` file inside the d

Before calling `repair()`, close a database if it's using the same `location`.

## Ordering

All write operations are asynchronously dispatched on the node thread pool and therefore the ordering
is not guaranteed.
ronag marked this conversation as resolved.
Show resolved Hide resolved

Consider:

``js
await Promise.all([
db.put('foo', 1)
db.put('foo', 2)
])
const result = await db.get('foo)
ronag marked this conversation as resolved.
Show resolved Hide resolved
```

The value of `result` could be either `1` or `2` depending on thread pool scheduling.
ronag marked this conversation as resolved.
Show resolved Hide resolved

Furthermore since reads fetch the snapshot immediatly, writes will not be visible until at latest
Copy link
Member

Choose a reason for hiding this comment

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

This is not entirely true: Level/leveldown#796 (same applies to classic-level).

Let's leave this paragraph (and the example) out for now, because I fear it will only create more confusion, at least until we fix Level/leveldown#796 (or decide that the current behavior is desirable, maybe).

Copy link
Member

Choose a reason for hiding this comment

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

Agreed with @vweevers :)

after the write promise has resolved.

``js
await db.put('foo', 1)
db.put('foo', 2)
const result = await db.get('foo')
```

The value of `result` will be `1`.

## Development

### Getting Started
Expand Down