Comments (3)
I see. Thanks.
Then docs should be updated. In docs, there is:
tx, err := st.NewTx(context.Background(), &store.TxOptions{Mode: store.ReadWriteTx})
As we see, this is not a problem in this concrete example in docs, but it leads to the error like I have made. Example should use store.DefaultTxOptions()
to tell the (future) user about this.
from immudb.
What happened
I made a transaction and committed a value under a key. In the next transaction that key is not visible. But it is visible outside of the transaction (when using
db.Get
).What you expected to happen
I expect that committed data is available in transactions.
How to reproduce it (as minimally and precisely as possible)
package main import ( "context" "log" "github.com/codenotary/immudb/embedded/appendable" "github.com/codenotary/immudb/embedded/store" ) func main() { opts := store.DefaultOptions() opts = opts.WithSyncFrequency(0) opts = opts.WithCompressionFormat(appendable.NoCompression) db, err := store.Open("/tmp/data", opts) if err != nil { log.Fatal(err) } defer db.Close() tx, err := db.NewTx(context.Background(), &store.TxOptions{Mode: store.ReadWriteTx}) if err != nil { log.Fatal(err) } defer tx.Cancel() key := []byte("foo") value := []byte("bar") err = tx.Set(key, nil, value) if err != nil { log.Fatal(err) } _, err = tx.Commit(context.Background()) if err != nil { log.Fatal(err) } tx, err = db.NewTx(context.Background(), &store.TxOptions{Mode: store.ReadOnlyTx}) if err != nil { log.Fatal(err) } ref, err := tx.Get(context.Background(), key) if err != nil { log.Fatal(err) } value, err = ref.Resolve() if err != nil { log.Fatal(err) } log.Printf("%v", string(value)) }
Environment
I use Go with immudb embedded at version v1.9.0-RC2.0.20231220125802-d143b42683b7.
Additional info (any other context about the problem)
It might be that transactions in immudb work differently than they do in traditional databases. But there you can fetch data committed in prior transactions when you are inside a new transaction. They behave like a snapshot (also provide isolation against changes in other parallel transactions).
Hi @mitar, transactions in immudb work pretty much as you would expect from any other database. Transactions are full ACID compliant with strict isolation.
I think the only issue with the code above is that the transactions options struct is built in a raw manner without a helpful constructor. Then it's not imposing any requirement for the snapshot used for the second transaction
tx, err = immuStore.NewTx(context.Background(), store.DefaultTxOptions().WithMode(store.ReadOnlyTx))
Please take a look at here https://github.com/jeroiraz/immudb/blob/9cfa35003ce361c3df4d53465d41b724bcee5018/embedded/store/immustore_test.go#L3739
from immudb.
I made codenotary/immudb.io#506 to update docs. Thanks.
from immudb.
Related Issues (20)
- Dockerfile IMMUDB_ADMIN_PASSWORD not support HOT 1
- ImmuDB 1.5.0 Chart missing from Helm index HOT 4
- ARM64 Support for ImmuDB HOT 5
- Question: History with SQL HOT 1
- service install the config option not work HOT 1
- Wrong error message when (mis)using aggregate functions
- Incorrect result: `UNION` does not deduplicate rows HOT 2
- SELECT after INSERT in transaction (regression)
- Immudb instance doesn't load data from S3 storage after reboot (randomly, discarding snapshots and other data) HOT 5
- Setting ImmuDB embedded Store MaxKeyValue is not working HOT 1
- Instead of checking subfolders of the remote storage immudb checks it from the root.
- Set admin password on AWS EC2 image using user data
- New immudb instance with S3 options turned on cause a startup error HOT 1
- The immudb logs are not availabe HOT 6
- immudb replica uses too much RAM
- Deleted data is still accessible using history
- tx read conflict error on a concurrent read HOT 1
- Error deploying immudb on EKS cluster with EBS added HOT 1
- Getting Error: indexed key of unsupported type or exceeded length: can not create index HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immudb.