| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
| |
1) First, as a cleanup, remove DB `Options` from the `init_db/3 call. We always
follow `init_db/3` (sometimes called through the
`fabric2_fdb:transactional(DbName, ...)` with a `create(TxDb, Options)` or
`open(TxDb, Options)` call, where we overrode `Options` anyway. The only time
we didn't follow it up with a `create/2` or `open/2` is when dbs are deleted
where `Options` wouldn't matter.
2) Add a new `fabric2_fdb:transactional(DbName|Db, TxOptions, Fun)` call which
allows specifying per-transaction TX options in the `TxOptions` arg. The format
of `TxOptions` is `#{option_name_as_atom => integer | binary}`
|
| |
|
|
|
|
|
| |
This is useful so that read conflicts on the changes feed will
eventually be resolved. Without an end key specified a reader could end
up in an infinite conflict retry loop if there are clients updating
documents in the database.
|
| | |
|
| |
|
|
|
|
|
|
|
| |
Waiting for the timeout option to be set means we could still sneak in
and grab the old FDB database handle before fabric2_server updated it in
the application environment.
This new approach just waits until the handle has been updated by
watching the value in the application environment directly.
|
| |
|
|
|
|
| |
The encryption object contains a boolean "enabled"
property. Additional properties might be added by the key manager
which will appear in the "key_manager" sub-object.
|
| | |
|
| |\ |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| | |
If a filtered changes feed hit a rewind we would send a bare `integer()`
value for the Seq. If this was used again during a rewind it causes a
competely rewind to zero due to not having the `node()` and UUID
`binary()` values to calculate a new start seq.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is the `couch_jobs` abstraction module. All replicator calls to
`couch_jobs` should go through it. This module takes care of adding types to
some of the API calls, handles maintencence of the RepId -> JobId mappings when
jobs are added and removed, and some subscription logic.
`fabric2.hrl` include file is updated with the definition of the
`?REPLICATION_IDS` prefix where the RepId -> JobId keyspace lives.
|
| | |
| |
| |
| |
| |
| | |
`after_db_create/2` and `after_db_delete/2` are when databases are created and
deleted respectively. The callbacks are called with both the database name and
the database instance UUID values.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This makes it compatible with CouchDB <= 3.x where we can create deleted
documents.
How to check:
```
$ http put $DB1/mydb
$ http put $DB1/mydb/foo _deleted:='true' a=b
{
"id": "foo",
"ok": true,
"rev": "1-ad7eb689fcae75e7a7edb57dc1f30939"
}
```
|
| | |
| |
| |
| |
| |
| |
| | |
Empty maps maybe useful to initialize the data in some cases but we don't want
to emit an entry in the output with just an empty map.
While at it, add some tests to check the basics.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previously, if a database was re-created on another node, a request with that
database might have found the previous db instance in the cache. In that case
it would have correctly reopened the db while in a transaction, but, because
the old db instance was deleted it would throw a database_does_not_exist which
was not the correct behavior.
To prevent that from happening, introduce an interactive = true|false option
when opening a database. User requests may specify that option and then when
the db is re-opened, it will allow it to automatically upgrade to the new db
instance instead returning an error.
Background processes will still get a database_doest_not_exist error if they
keep a db open which has now been re-created.
The interactive option may also be used in the future to set other transaction
parameters like timeouts and retries that might be different for interactive
requests vs background tasks.
|
| | | |
|
| | |
| |
| |
| |
| | |
Instead of relying on couch_task_status, we use fabric2_active_tasks
to construct active_task info via couch_jobs.
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| | |
As per ML
[discussion](https://lists.apache.org/thread.html/rb328513fb932e231cf8793f92dd1cc2269044cb73cb43a6662c464a1%40%3Cdev.couchdb.apache.org%3E)
add a `uuid` field to db info results in order to be able to uniquely identify
a particular instance of a database. When a database is deleted and re-created
with the same name, it will return a new `uuid` value.
|
| | |
| |
| |
| |
| |
| | |
Update db handles right away as soon we db verison is checked. This ensures
concurrent requests will get access to the current handle as soon as possible
and may avoid doing extra version checks and re-opens.
|
| | |
| |
| |
| |
| |
| | |
Check metadata versions to ensure newer handles are not clobbered. The same
thing is done for removal, `maybe_remove/1` removes handle only if there isn't
a newer handle already there.
|
| | |
| |
| |
| | |
Observed a number of timeouts with the previous default
|
| | |
| |
| |
| |
| | |
In a constrained CI environment transactions could retry multiple times so we
cannot rely on precisely counting erlfdb:transactional/2 calls.
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* Interactive (regular) requests are split into smaller transactions, so
larger updates won't fail with either timeout so or transaction too large
FDB errors.
* Non-interactive (replicated) requests can now batch their updates in a few
transaction and gain extra performance.
Batch size is configurable:
```
[fabric]
update_docs_batch_size = 5000000
```
|
| | | |
|
| | |
| |
| |
| |
| |
| | |
Add some longer timeouts and fix a race condition in db cleanup tests
(Thanks to @jdoane for the patch)
|
| | |
| |
| |
| |
| |
| |
| |
| | |
allow background job to delete soft-deleted database according to
specified criteria to release space. Once database is hard-deleted,
the data can't be fetched back.
Co-authored-by: Nick Vatamaniuc<vatamane@apache.org>
|
| | | |
|
| | | |
|
| | |
| |
| |
| |
| | |
On CI creating a 100 dbs in a row was too much to do in 5 seconds so bump it to
15.
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| | |
And an extra level of error checking to erlfdb:set_option since it could fail
if we forget to update erlfdb dependency or fdb server version is too old. That
operation can fail with an error:badarg which is exactly how list_to_integer
fails and result in a confusing log message.
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
With the latest erlfdb release v1.1.0 we have the ability to set default
transaction options on the database handle. Once set, those are inherited by
every transaction started from that handle.
Use this feature to give advanced users a way to experiment with various
transaction options. Descriptions of those options in the default.ini file have
been mostly a copy and paste from the fdb_c_option.g.h file from the client
library.
In addition, specify some safer default values for transaction timeouts (1min)
and retry limit (100). These quite conservative and are basically something
less that "infinity". In the future these may be adjusted lower.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A new application, aegis, is introduced to provide strong at-rest
protection of CouchDB data (where possible).
Currently we encrypt the following values (if enabled):
1. Document content
2. Attachment content
3. Index values
Things not encrypted:
1. _all_docs
2. _changes
3. doc id
4. doc rev
5. Index keys
6. All other metadata
Co-Authored-By: Eric Avdey <eiri@apache.org>
Co-Authored-By: Robert Samuel Newson <rnewson@apache.org>
|
| | |
| |
| |
| |
| |
| |
| |
| | |
Adds a fold_docs function that will do a parallel fetch for the supplied
Doc Ids. This is used for _all_docs?keys=["id1", "id2"].
This uses a queue for fetching the revs and another queue for fetching
the doc bodies. These queues will be drained if the future queue gets
to large.
|
| | |
| |
| |
| |
| | |
Use a common `get_revs_future` and `get_revs_wait` for fetching
winning revs and all revs.
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
By default, transactions are used to check metadata, and possibly
reopen the db, to get a current db handle. However, if a `max_age`
option is provided and db handle was checked less than `max_age`
milliseconds ago, use properties from that cached handle instead.
The main use of this feature be in pluggable authorization handlers
where it might be necessary to inspect the security doc multiple times
for the same request before a final decision is made.
`revs_limit/1` was updated as well, mainly for consistency since it is
almost identical to `get_security/1`.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
- Rename `clear_expired_range` to `clear_range_to`
- Move `EXPIRING_CACHE` layer prefix into fabric2.hrl
- Move primary key setting to just after key & value calculations
- Factor out `get_val/2` to lookup a key from FDB and unpack the value
- Factor out `prefixes/2`
- Factor out `fold_range/5`
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently, the size of binary chunks used for values is fixed at the FDB
imposed limit of 100kB, although they recommend using 10KB [1], (also
note they subtly change units).
This makes that value configurable, allowing e.g. benchmarks to compare
performance of runs with varying chunk size. The cost is a ~10µs config
lookup penalty each time data needs to be chunked.
[1] https://www.foundationdb.org/files/record-layer-paper.pdf
|
| | | |
|
| | |
| |
| |
| |
| | |
Each registered index type can now get a signal on when to clean up
their indexes.
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| | |
Functions are easier to read and process if they're defined in the order
that they are referenced.
Co-Authored-By: Nick Vatamaniuc <vatamane@apache.org>
|
| | |
| |
| |
| |
| |
| |
| |
| | |
Usually we indicate the transaction status of a Db handle by naming it
`TxDb`. This updates fabric2_index:build_indices/2 to match that
pattern.
Co-Authored-By: Nick Vatamaniuc <vatamane@apache.org>
|
| | |
| |
| |
| |
| |
| | |
Previously in the the test we first set up the callback, then disabled the
indexing. By that time, there was a chance that building could have started
especially in a slower execution environment.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In CouchDB < 4.x we compressed document bodies by default, so enable it
for 4.x as well.
Use the basic term_to_binary compression mechanism for:
- Document bodies
- Local document bodies
- Attachments, but only if they have not already been compressed.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
Instead of automatically and immediately removing data and index in
database after a delete operation, soft-deletion allows to restore
the deleted data back to original state due to a “fat finger”or
undesired delete operation, up to defined periods, such as 48 hours.
Co-Authored-By: Paul J. Davis <paul.joseph.davis@gmail.com>
|
| | |
| |
| |
| |
| |
| | |
This creates a versionstamp for when an indexed was created
and build status for indexes. if the index has a creation_vs, then
couch_views_indexer will built the index to this creation versionstamp.
|