20 Commits
Author SHA1 Message Date
Matthew McNeelyandGitHub 56b2d31d75 chore: update README.md with correct links and badges (#2239)
**Description**

Updated links

Closes #2238
2025-12-10 22:11:18 +00:00
Ryan Fox-TylerandGitHub 94498ea84c chore: align repo conventions (#2158) 2025-02-05 17:00:32 -05:00
f1a4ebf1cb Clean up transaction oracle as we go (#1275)
In the existing implementation of oracle, if you happen to always have at least
one write transaction open the memory usage of the transaction oracle is
unbounded. It is actually relatively easy to hit when batch importing data. If
you have more than one WriteBatch active during the import the transaction
oracle will never be cleaned up.

This commit fixes it. The core idea is to avoid increasing contention on purely
read transactions; so only clean up the transaction oracle when write
transactions are committed even if technically we could free memory sooner;
Split the big `oracle.commit` map into one map per previously committed
transaction; (this allows Go to release memory sooner than when performing
deletes on a single map);

Take advantage of the fact that we have acquired the oracle lock in
oracle.newCommitTs to do the cleanup I am assuming here that the number of
committed-but-still-tracked transactions is small, which makes an
implementation based on a simple slice reasonable. If that's not the case we
will need some form of a sorted data-structure (i.e. a b-tree) here.

Co-authored-by: Damien Tournoud <damien@platform.sh>
2020-05-18 18:30:18 +05:30
Ibrahim JarifandGitHub 25deb5200e Handle duplicates in ManagedWriteBatch (#1315)
When duplicate entries with different versions are inserted, the
current implementation would store only the latest update and
drop all the previous ones. This PR fixes it. We keep all
duplicate entries in ManagedWriteBatch.
2020-04-30 15:41:40 +05:30
Ibrahim JarifandGitHub 03ea87e26d Support entry version in Write batch (#1310)
This PR adds support for setting different versions for different
keys in write batch. The existing implementation of write batch
allows setting only a single version for all keys in the write batch.
With this PR, user can do the following
```
wb := db.NewManagedWriteBatch()
wb.SetEntryAt(e, ts)
wb.Flush()
```

Also, the existing behavior of `txn.Commit()` in `un-managed
(normal) mode` is to panic, the new behavior would be to
return an error.
2020-04-21 11:54:41 +05:30
Ibrahim JarifandGitHub 0a8925eda3 Support WriteBatch API in managed mode (#948)
This commit adds a new `WriteBatchAt(commitTs)` API which allows the user to use 
write batch in managed mode.

Fixes https://github.com/dgraph-io/badger/issues/944
2019-08-03 12:17:34 +05:30
Manish R Jain f609621d8a Support WriteBatch.SetWithTTL as requested in #649. 2018-12-31 13:45:06 -08:00
Manish R JainandGitHub f6e0ee6183 Rewrite DropAll to not use deletion markers (#651)
- Do not use deletion markers during DropAll, because that causes writes at lower timestamps to be ignored (in managed DB mode).
- Instead, delete all SSTables and all log files, and reset value log and value log head to zero.
- Make DropAll open to all users of Badger, including normal mode.

Changelog:
* Do not use delete markers in DropAll. Instead, delete the entire LSM tree and all the value logs.
* Moved DropAll to db.go, so it is available to all users of Badger. Fixed a bug where we were not catching memtable flushes during DropAll.
* Make DropAll test more races. Catch another place where writes should fail due to blockedWrite.
* Self-review
2018-12-26 19:22:33 -08:00
Manish R JainandGitHub 17c947cedc Create a WriteBatch API to allow efficient serial writes (#608)
**Breaking change**

- This change removes the ability to provide a callback in Commit. Instead, it creates another function called CommitWith, which takes a callback.
- Previously, a user-specified callback might or might not get executed. This PR fixes that by guaranteeing that the commit callback is always executed.
- Create a WriteBatch API to batch up multiple updates into a single txn. The txn gets Committed via callback, so the user gets a simple efficient way to do a lot of writes.
- Run only a few goroutines to execute these user callbacks. Previously, we were shooting off one goroutine per Commit callback.
2018-10-08 18:05:00 -07:00
Manish R Jain c9154bfba8 Keep managedTxns option internal, so users have to use OpenManaged explicitly to open Badger. 2018-10-02 15:05:04 -07:00
Manish R JainandGitHub f9d7851910 Merge ManagedDB back into DB (#568)
* Remove the extra ManagedDB struct, which was causing maintenance headaches, due to the way Go handles polymorphism. Instead just expose the ManagedTxns option, and use it directly.

* Bring back the OpenManaged function for convenience.
2018-09-19 10:44:01 -07:00
Manish R Jain 47d76c1edc Use the same timestamp to delete keys as their latest versions. Thus, we can write back keys at the same timestamp without fear of losing them. 2018-07-12 15:02:33 -07:00
Manish R JainandGitHub dbf53a1b15 Add a DropAll method in ManagedDB (#525)
This method drops all tables from the LSM tree, except one to maintain the persistence of badgerHead key. This is important to avoid value log being replayed from scratch.

It then iterates over the rest of the keys and marks them as deleted. The end result should be that all keys are considered deleted.

This method would perform a lot better than deleting every key via iteration.

NOTE to users: The timestamp used for writes must be greater than the max timestamp of writes before DropAll, to ensure that new writes are not lower than the delete markers in terms of versioning.
2018-07-12 14:23:49 -07:00
Manish R Jain 447380eb16 Allow ManagedDB to set a discard below timestamp. So, only versions below this timestamp get discarded, hence ensuring that we keep all the versions since the last snapshot. 2018-07-11 15:35:56 -07:00
Manish R JainandGitHub ba16590b03 Add a new SetWithDiscard method. (#475)
Add a new SetWithDiscard method, which indicates discarding of earlier versions. This information is used by compaction to discard versions. Value log GC can then discard key-value pairs which are no longer in the LSM tree (due to removal by compactions). Thus, this simple change removes the need to have PurgeBelowTs and other PurgeOlderVersions methods. Note that PurgeOlderVersions method is already made obsolete by NumVersionsToKeep option.

Only the flip side, this would make the prediction of which value log can be removed harder. Though, compaction can tackle that by updating the discard stats for value log. Maybe in another PR.

Also simplifies MergeOperator code.
2018-05-04 18:56:43 -07:00
Deepak Jois c1e6d56faa Fix some warnings in code added while implementing DB.GetSequence() 2017-12-12 08:35:07 +05:30
Manish R Jain 2c90a78e70 Add the NextSequence feature
- Add a GetSequence() method, which can hand out Sequence object.
- Add a Next() method on Sequence object, which is thread-safe.
- Panic for this function on ManagedDB.
- Add corresponding docs in README.
2017-12-11 16:02:56 +11:00
Janardhan ReddyandGitHub 8542b26181 add purgeversions below for managed_db (#288)
add purgeversions method on managed_db
2017-10-25 12:53:20 +11:00
Deepak Jois e5e18b3eb2 Remove panic from Txn.Commit() and Txn.CommitAt(). 2017-10-24 09:40:15 +05:30
Deepak Jois 20de108929 Introduce ManagedDB struct to perform managed transactions.
This is a bit of a cleanup of #280 (committed as
8fa1d7f577)

* Make ManagedTxns option private, so that it can be set only within the
package.

* Introduce a separate struct ManagedDB, which embeds badger.DB.

* Introduce ManagedDB.NewTransaction() and ManagedDB.NewTransactionAt()
methods.

* Introduce Txn.CommitAt, applicable only to ManageDB.
2017-10-23 16:10:02 +05:30