Results 1 to 2 of 2

Thread: 4.0.5, exceptions were thrown on all methods.

  1. #1
    Junior Member
    Join Date
    Nov 2014
    Posts
    1

    Default 4.0.5, exceptions were thrown on all methods.

    I'm using 4.0.5 and I have to say I really love it! It was the fastest object database I've ever used. But after I ran my codes for 20 more hours and inserted about 300k records, everything went wrong. All methods are throwing exceptions either "An element with the same key already exists" or "one or more errors occurred". I don't know what happened so I delete the database file and restart my program, and after several hours it happened again.
    I really don't want to give up stsdb, this is the best object database I know, so I think I really can use some help.

    here is my codes using stsdb. Did you see any potential bad code which can cause my problem? BTW, all exceptions was thrown from stsdb dll codes, not my codes, which actually make unable to track it.

    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.IO;
    using System.Linq;
    using STSdb4;
    using STSdb4.Database;
    
    
    namespace TiebaUserWorm
    {
        public class DataPack
        {
            private IStorageEngine _db;
            private ITable<string, Tieba> _tiebaDb;
            private ITable<string, BaiduUser> _userDb;
            private ITable<Guid, Relation> _relationDb;   
    
    
            public DataPack()
            {
                _db = STSdb.FromFile(ConfigurationManager.AppSettings["WormDataBasePath"]);
                _tiebaDb = _db.OpenXTable<string, Tieba>("Tieba");
                _userDb = _db.OpenXTable<string, BaiduUser>("User");
                _relationDb = _db.OpenXTable<Guid, Relation>("Relation");
            }
    
    
            public void Store(Tieba ti)
            {
                _tiebaDb[ti.Name] = ti;
            }
    
    
            public void Store(BaiduUser bu)
            {
                _userDb[bu.Name] = bu;
            }
    
    
            public void Store(Relation rl)
            {
                _relationDb[Guid.NewGuid()] = rl;
            }
    
    
            public BaiduUser GetUser(string un)
            {
                if (_userDb.Exists(un))
                {
                    return _userDb[un];
                }
                return null;
            }
    
    
            public Tieba GetTieba(string tbn)
            {
                if (_tiebaDb.Exists(tbn))
                {
                    return _tiebaDb[tbn];
                }
                return null;
            }
    
    
            public BaiduUser GetNextFanAvailableUser()
            {
                var res = _userDb.Where(user=>user.Value.UsedForUser == false);
                BaiduUser ret = res.FirstOrDefault().Value;
                if (ret == null) return null;
                ret.UsedForUser = true;
                _userDb[ret.Name] = ret;
                //_db.Commit();
                return ret;
            }
    
    
            public BaiduUser GetNextTiebaAvailableUser()
            {
                var res = _userDb.Where(user => user.Value.UsedForTieba == false);
                BaiduUser ret = res.FirstOrDefault().Value;
                if (ret == null) return null;
                ret.UsedForTieba = true;
                _userDb[ret.Name] = ret;
                //_db.Commit();
                return ret;
            }
    
    
            public Tieba GetNextAvailableTieba()
            {
                var res = _tiebaDb.Where(user => user.Value.Used == false);
                Tieba ret = res.FirstOrDefault().Value;
                if (ret == null) return null;
                ret.Used = true;
                _tiebaDb[ret.Name] = ret;
                //_db.Commit();
                return ret;
            }
    
    
            public void Commit()
            {
                _db.Commit();
            }
    
    
            public void GetDataCount(out long users, out long tiebas, out long relations)
            {
                users = _userDb.Count();
                tiebas = _tiebaDb.Count();
                relations = _relationDb.Count();
            }
    
    
            public void Close()
            {
                _db.Close();
            }
        }
    }
    

  2. #2

    Default

    Greetings.

    It will be helpful if you provide a full definition of your record types as well as a code snippet that reproduces the problem, so that we can test and analyze it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
2002 - 2014 STS Soft SC. All Rights reserved.
STSdb, Waterfall Tree and WTree are registered trademarks of STS Soft SC.