summaryrefslogtreecommitdiff
path: root/src/fabric
Commit message (Collapse)AuthorAgeFilesLines
* Allow applying per-transaction options with fabric2_fdb:transactional/3Nick Vatamaniuc2021-03-033-24/+71
| | | | | | | | | | | | | 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}`
* Allow specifying an end_key for fold_changesPaul J. Davis2020-11-172-7/+22
| | | | | | | 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.
* Allow snapshots through fabric2_fdb:transactionalPaul J. Davis2020-11-172-0/+151
|
* Fix flaky testPaul J. Davis2020-11-101-2/+8
| | | | | | | | | 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.
* Add an "encryption" object to db infoaegis_db_infoRobert Newson2020-11-061-1/+3
| | | | | | 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.
* Export fabric2_fdb:chunkify_binary/1,2Paul J. Davis2020-09-301-15/+18
|
* Merge branch master into prototype/fdb-layerPaul J. Davis2020-09-162-2/+184
|\
| * Ensure shards are created with db optionsRussell Branca2020-03-252-1/+182
| |
| * Send correct seq values for filtered changesPaul J. Davis2020-03-111-1/+2
| | | | | | | | | | | | | | 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.
* | Introduce couch_replicator_jobs abstraction moduleNick Vatamaniuc2020-09-151-0/+1
| | | | | | | | | | | | | | | | | | | | 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.
* | Add after_db_create/2 and after_db_delete/2 callbacks to fabricNick Vatamaniuc2020-09-152-3/+22
| | | | | | | | | | | | `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.
* | Allow creating new deleted documentsNick Vatamaniuc2020-09-032-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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" } ```
* | Handle empty maps in active_tasks data structuremaserNick Vatamaniuc2020-09-012-1/+122
| | | | | | | | | | | | | | 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.
* | Allow interactive requests to reopen a re-created db instanceNick Vatamaniuc2020-07-315-21/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Add format_status/2 callback in gen_server implementationsILYA Khlopotov2020-07-301-1/+14
| |
* | add support for active_tasks via fabric2Tony Sun2020-07-241-0/+51
| | | | | | | | | | Instead of relying on couch_task_status, we use fabric2_active_tasks to construct active_task info via couch_jobs.
* | Reserve aegis namespace under ?CLUSTER_CONFIGEric Avdey2020-06-171-0/+4
| |
* | Include database uuid in db info resultNick Vatamaniuc2020-06-043-5/+16
| | | | | | | | | | | | | | | | 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.
* | Remove on_commit handler from fabric2_fdbNick Vatamaniuc2020-06-022-47/+26
| | | | | | | | | | | | 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.
* | Prevent eviction of newer handles from fabric_server cacheNick Vatamaniuc2020-06-022-9/+70
| | | | | | | | | | | | 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.
* | Lower the default batch size for update_docs to 2.5MBNick Vatamaniuc2020-05-271-1/+1
| | | | | | | | Observed a number of timeouts with the previous default
* | Remove erlfdb mock from update_docs/2,3 testNick Vatamaniuc2020-05-221-14/+0
| | | | | | | | | | In a constrained CI environment transactions could retry multiple times so we cannot rely on precisely counting erlfdb:transactional/2 calls.
* | Improve log of permanently deleting databasesimprove-db-expiration-logjiangph2020-05-211-2/+2
| |
* | Bulk docs transaction batchingNick Vatamaniuc2020-05-203-28/+375
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 ```
* | Fix compiler warningJay Doane2020-05-141-1/+1
| |
* | Fix a few flaky tests in fabric2_dbNick Vatamaniuc2020-05-134-17/+22
| | | | | | | | | | | | Add some longer timeouts and fix a race condition in db cleanup tests (Thanks to @jdoane for the patch)
* | background deletion for soft-deleted databasejiangph2020-05-134-3/+358
| | | | | | | | | | | | | | | | 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>
* | add local_docs to fold_doc with docidsGarren Smith2020-05-083-23/+228
| |
* | Convert aegis key cach to LRU with hard expiration timeEric Avdey2020-05-071-0/+8
| |
* | Fix list_dbs_info_tx_too_old flaky testNick Vatamaniuc2020-04-291-1/+1
| | | | | | | | | | On CI creating a 100 dbs in a row was too much to do in 5 seconds so bump it to 15.
* | Fix a flaky fdbcore index testNick Vatamaniuc2020-04-291-2/+2
| |
* | Re-enable the tx options testsNick Vatamaniuc2020-04-282-3/+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.
* | Temporary disable fabric2_tx_options_testsEric Avdey2020-04-281-1/+1
| |
* | Allow specifying FDB transaction optionsNick Vatamaniuc2020-04-273-11/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Add native encryption supportRobert Newson2020-04-273-14/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Add fold_docs for DocId listGarren Smith2020-04-231-0/+142
| | | | | | | | | | | | | | | | 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.
* | Refactor fetching rev code in fabric2_fdbGarren Smith2020-04-232-19/+19
| | | | | | | | | | Use a common `get_revs_future` and `get_revs_wait` for fetching winning revs and all revs.
* | Fetch doc in same transaction as _all_doc rowGarren Smith2020-04-171-1/+1
| |
* | Allow using cached security and revs_limit propertiesNick Vatamaniuc2020-04-163-11/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | Refactor expiring cache FDB interfaceJay Doane2020-04-151-0/+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`
* | Enable configurable binary chunk sizeJay Doane2020-04-152-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Optionally cleanup stale indices automaticallyPaul J. Davis2020-04-101-5/+17
| |
* | Extend fabric2_index callbacks for index cleanupPaul J. Davis2020-04-101-0/+23
| | | | | | | | | | Each registered index type can now get a signal on when to clean up their indexes.
* | Update to use `fabric2_db:get_design_docs/1`Paul J. Davis2020-04-101-17/+1
| |
* | Move process_db/1 to match the logical progressionPaul J. Davis2020-04-101-10/+10
| | | | | | | | | | | | | | 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>
* | Rename variables to indicate transaction statePaul J. Davis2020-04-101-3/+3
| | | | | | | | | | | | | | | | 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>
* | Fix flaky fabric2_index testNick Vatamaniuc2020-04-101-3/+3
| | | | | | | | | | | | 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.
* | Compress doc bodies and attachmentsNick Vatamaniuc2020-04-074-11/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Support soft-deletion in fabric leveljiangph2020-04-075-14/+515
| | | | | | | | | | | | | | | | | | 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>
* | Add couch_views_indexer build to creation versionstampGarren Smith2020-04-061-5/+7
| | | | | | | | | | | | 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.