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

Curious intermittent bug SQLite3 and beedb #11

Open
ghost opened this issue Aug 30, 2012 · 6 comments
Open

Curious intermittent bug SQLite3 and beedb #11

ghost opened this issue Aug 30, 2012 · 6 comments

Comments

@ghost
Copy link

ghost commented Aug 30, 2012

This is becoming more prevalent. I'm having some trouble with orm.FindAll. The test data in the database is:

1|1|458|1|45000|Debtor has other outstanding obligations|1344643200|1351036800|5|13000000|4380000|1260000|890000|

I print the object after the select and get quite a different result:

&{0 0 0 0 0 Debtor has other outstanding obligations 0 0 5 0 0 0 0 0}

beedb's debug output from that resembles: &{0xf840137300 judgements 0 0 [] attorneyfeesbalance, account, duedayofmonth, interestbalance, bank, statutedate, id, monthlypayment, judgementdate, notation, bankexpensesbalance, principalbalance, apr, lastinterestdate Id ` ? 1}

The fields that get zeroed out are random every time. About 25% of the time, the entire record is returned intact. I had this problem before and I thought it had gone away with your latest fix. If I use Mattn's drivers directly, I don't have intermittent results like this. I can help in any way possible, the drivers are otherwise excellent.

SQLite 3.7.13
Linux Gothmaug 3.4.4-gentoo #1 SMP PREEMPT Tue Jul 17 17:53:20 EDT 2012 x86_64 AMD Phenom(tm) 9950 Quad-Core Processor AuthenticAMD GNU/Linux

@astaxie
Copy link
Owner

astaxie commented Aug 30, 2012

What's definiton about the struct;for the int type try int64

@ghost
Copy link
Author

ghost commented Aug 30, 2012

This appears to be using the same pointer address for multiple reads. I wonder if this has anything to do with my issue.

@ghost
Copy link
Author

ghost commented Aug 30, 2012

I changed all the code over to int64 and the issue persists. here is a (very) rough outline of how my app works: https://gist.github.com/3530821 I'm still struck by how the pointer addresses reported by beedb are the same. I'm going to work on some way of getting the records out of the 'db goroutine' to the main goroutine by val instead of the pointers.

@astaxie
Copy link
Owner

astaxie commented Sep 1, 2012

i have no idea about this issue

@MaximBoyarskiy
Copy link

Hello,

I had some similar issue. I had a table (with some data) and I added another column with int type (without default 0 value). All existent row got "" (empty) value for this column. After adding I had the same problem - different results for the same queries. I noticed that for int column beedb adds 0 in there is no value. I removed my new column and added it again with default 0 value. All existent rows got 0 for that new column. And it was fixed - same results for same queries. I use Sqlite3 extension for Firefox for managing sqlite db.

I hope it will work for you too.

@astaxie
Copy link
Owner

astaxie commented Sep 19, 2012

yesterday when i review the pkg doc http://golang.org/pkg/database/sql/driver/#Driver

i find the driver definition

type Driver interface {
// Open returns a new connection to the database.
// The name is a string in a driver-specific format.
//
// Open may return a cached connection (one previously
// closed), but doing so is unnecessary; the sql package
// maintains a pool of idle connections for efficient re-use.
//
// The returned connection is only used by one goroutine at a
// time.
Open(name string) (Conn, error)
 }

The returned connection is only used by one goroutine at a time.

the problem maybe calls by the goroutine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants