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

"unable to open database file", intranet library, is read only? #257

Open
SimonDedman opened this issue Oct 23, 2020 · 59 comments
Open

"unable to open database file", intranet library, is read only? #257

SimonDedman opened this issue Oct 23, 2020 · 59 comments
Labels
🐛bug Something isn't working
Milestone

Comments

@SimonDedman
Copy link

qiqqaSync1

qiqqaSync2

Screenshots of issues above. Setup is: watch folder & qiqqasync directory both in a local network directory which opens and can be edited fine, as far as I can tell. I'm able to setup the intranet library but when I try to full sync I get the above errors.

I have another machine with the same setup and it works fine. I'd been using that machine (home) all day, then tried to sync the other machine (work). Qiqqa was closed on the home machine.

Any ideas gratefully received. Cheers!

@GerHobbelt
Copy link
Collaborator

Phew, this might be an issue with SQLite databases and network storage, though that's "usually" reported as crap happening on DropBox shares and the like (cloud storage).

Thanks for the screenshots: what I can glean from there is that I probably need to augment that error report so that we can dig up on what database file exactly SQLite is barfing a hairball.


On another note I do recall so old trouble back in '19 with the whole Qiqqa Sync business, which had a few lines from the commercial age being obstructive, but then that should have been gone out the window by window.

Got to dig in, so don't expect anything useful before the weekend.

Plan of attack in my mind right now:

  • me: augment the error report so we can see paths and maybe a little more detail
  • me: publish that in a new release
  • you: install new release and then run that one to see what gives
  • you: collect log files (same as Qiqqa crashing #264) and emailing them to me
  • me: log/error analysis and hopefully a lucid moment right there 😉

P.S.: just doublechecking here to make sure I can tick off the scare in my brain: both machines still have a working Qiqqa and Qiqqa libraries, right?

@GerHobbelt GerHobbelt added the 🐛bug Something isn't working label Oct 27, 2020
@SimonDedman
Copy link
Author

Cheers for the wonderfully thought-out plan! :)

Yep - both having working Qiqqa, just getting the intranet library working on the second doesn't work, even though I'm using the same approach as on the first.

One thought is that I don't know with 100% certainty that both machines are setup EXACTLY the same way in terms of reaching the NAS. Now, I think they are. But browsing to the NAS as a network drive took more steps on the home machine (that works) than the work machine, which worked straight off the bat. Now they look and function the same but I don't know if there's any small difference behind the scenes. I suspect this isn't the issue but I figured I'd mention it just in case.

On a completely separate note, I noticed that the Qiqqa getsatisfaction community has been removed; I wonder if it's possible for us to get an archive of this somehow (maybe Wayback machine)? I figure this could be quite useful since it's got a lot of community ideas for workarounds or bug discussions, so it could be a useful resource...

Cheers!

@GerHobbelt
Copy link
Collaborator

Before I'm off (near 1 AM now): I do recall some trouble with sync behaviour (enabled/disabled) back in '19. Given your problem, I must look into that part of the code again I expect. At least that's my initial hunch without any backing except "gut feeling, no data". We'll see what happens when I do an updated version of qiqqa for you around tomorrow or day after, depending on how things go with the day job.

On the separate note:

  • getsatisfaction going out of business #218
  • and since I was asleep at the wheel on that one (did a web grab, then nuked the webgrab, which was 😨 🤢 klunky anyway, as part of a large SSD cleanup for I needed room. Of course, Murphy being a best buddy I got under speed-dial, that happened after GS shut down. 🥶 Em?... Whoops?!
    • Interesting to note at the time: getsatisfaction going out of business #218 was Jimme giving a heads up, but when I looked as GS myself as a user the b-tards didn't give a peep about shutting down their 💩
      🤦

    • Had a bright moment and did a google / duckduckgo search for qiqqa+GS and got my grubby paws on the not-yet-obsoleted search engine cached versions of those files --> https://github.com/jimmejardine/qiqqa-open-source/tree/master/docs-src/getsatisfaction-mirror/____extracted -- that was a bit of Mechanical Turk work, but alas, I got the goods as far as possible.

      Needs more postprocessing, but that's what I got going through all the search result pages until the well ran dry. Skipped the spam pages that had been cached too, BTW.

    • Wayback Machine would have been an option, iff Qiqqa GS forum had been registered with them for waybacking: they don't do the entire internet and this, AFAICT, was not in their backups. If anyone finds Qiqqa GS in the Wayback machine, then I'd like to hear it, but my google foo delivered nada there.

[OK, that story isn't written in chronologic order. Hope it's intelligible anyway. Anyhoo, I'm off. Gotta go. 👋 ]

@SimonDedman
Copy link
Author

Interesting rollercoaster ride of a tale about the GS issues! I suspect there's not tons of useful stuff on there but you never know. I'm sure we'll find all the bugs again anyway!!

@GerHobbelt
Copy link
Collaborator

OK, looks like it's the sync target, i.e. the SQLite database file on the NAS, which might be damaged and SQLite barfing a hairball about this.

Have been digging around as I needed to see where I augment the logging, etc. and not yet reproduced your problem, but that should be fine for the next phase: running a Qiqqa update to test this in more detail.

WARNING NOTE

Since I gather from digging through the code and your screenshots of the failure that the NAS copy of your library is probably corrupt (the metadata store at least as the BibTeX etc. is stored in a SQLite database) and before we commence I urge you to back up your Qiqqa libraries from the local machine: nobody would be happy when that stuff gets damaged by a subsequent (newer) Qiqqa run after installing the Qiqqa test release that's going to be referenced in my next comment.

Best practice would be to backup the Qiqqa base directory and everything inside from the local machine and possibly of the NAS as well, just to be on the safe side and my preliminary guess turns out wrong. Personally, I would ZIP (or 7ZIP) the whole kaboodle; might want to use a "multiple volume 7ZIP" archive for that, i.e. tick the box in 7zip when creating the archive and you get archive file segments named archive.001, archive.002, etc.

Screenshots of how that might look:

image

^^^

would produce something like this

==>

image

(nitpick: those are screenshots from different actions, so base.7z in the first should be read as 'C9F0D079-EE4C-4A15-8547-72164A7A356D-updated-GHO.7z')

END OF WARNING NOTE

Link to Qiqqa update for testing coming up next....

GerHobbelt added a commit to GerHobbelt/qiqqa-open-source that referenced this issue Oct 29, 2020
… suitable, instead of brutally clipped off.

- added the Sync Target column at the right size in there, so you can see what Qiqqa thinks the current Sync Target directory might be. `(null)` when none has been set up.
- WARNING: this stuff is not yet editable!
- File.Copy() gives out a horrible user-unfriendly exception: path only, no cause, no blurb about it being the source or target either. Hackily fixed for the sync template database now. Must be inspected. MIGHT be just good enough for recovering from a broken sync target database like Simon Dedman in jimmejardine#257 is possibly sadled with. (IFF one goes and *manually* deletes the corrupted XYZ.s3db database file in that sync destination, anyway. Dangerous stuff. :-)
GerHobbelt added a commit to GerHobbelt/qiqqa-open-source that referenced this issue Oct 29, 2020
@GerHobbelt
Copy link
Collaborator

OK, new Qiqqa setup for you to try at https://drive.google.com/file/d/13gWzHHtL0dpRAJlSWZjweE3-3RWXFpxY/view?usp=sharing
which should give you access to a Google Drive download of setup-v82.0.7576.3604.exe

Make sure you've backed up your Qiqqa data before running this installer.

Once installed, run Qiqqa and see if you can reproduce the problem and see what Qiqqa says then in the logging. This time around Qiqqa should be a bit more verbose and also tell us which database file exactly triggered that b0rk.

(This is an unlabeled release, coded as v82.0.7576.3604 for commit SHA-1: 4433a6a )

Trouble that I expect to find over there:

  • given the screenshots posted and the code review I did tonight, the next hurdle would be how to approach recovering a broken SQLite database.
    • the easy way out there would probably be to nuke the *.s3db file in the NAS sync target directory and then let Qiqqa sync it all over again from scratch.

      However: I have not yet tested that 'desired behaviour' and you might end up with a borked library instead for whatever reason. Hence the plea to backup! backup! backup! first! 😅

  • Then there's the things I have to do to edit the sync target path, i.e. allow users to point the sync point of their Qiqqa libraries to a new location. That is still wishful thinking as it hasn't been coded yet (and tonight I feel about WPF/XAML like !@#$%^&*)

    That's not directly related to your issue, but since we're touching that chunk of the ware anyway, heck, might fulfil a long pending wish in the issue tracker, even when it's done in a hacky way maybe. 🤷‍♂️

  • For the rest, I'm open to surprises. (As in the original plan of attack: if you find anything or nothing, please send the log files for inspection when you feel you're done testing. Thanks!)

@GerHobbelt
Copy link
Collaborator

Oh, the new Qiqqa should show the Sync Target path in the sync manager dialog. That might also help the diagnosis a bit.

image

@GerHobbelt GerHobbelt added this to the v82 milestone Oct 29, 2020
@SimonDedman
Copy link
Author

Howdy! A thousand thanks for helping with this, again.

I installed the new version of qiqqa on my work machine. It looks like my original screenshot (second one) was cropped too far down, and the line before was key:
qiqqaNasSync

20201029.173706 [Q] ERROR [22] [24.238M] IntranetLibraryDB::GetItemsSummary: Database I/O failure for DB '\NAS\Si Work\Papers & Books\QiqqaSync\Qiqqa.LibraryMetadata.s3db'.

Sync target path is correct, \NAS\Si Work\Papers & Books\QiqqaSync

In my home machine (working, just did a full sunc successfully which is weird since you'd think it would announce a problem with Qiqqa.LibraryMetadata.s3db) I'll backup the NAS library then nuke that s3db file and try to sync it back (again from home machine) then see if the work machine, uh, works.

To be continued!

@SimonDedman
Copy link
Author

So: nuked Qiqqa.LibraryMetadata.s3db, resyned on home machine to rebuild it, successfully (on home machine), but no change on work machine. Thought: could it be that the database file has some form of machine-specific ID that leads it to be readable on the machine that set it up, but not on other machines?

Logs attached for the work machine.
!Qiqqa.ErrorsAndUserActions.log

In 'Properties' for that file, details in General (archive) and Security (Allow for all except 'full control') are the same on both machines.

Uninstalled & reinstalled Qiqqa on work machine. Upon reopening, my intranet library is present (with 0 docs as usual). This seems strange; maybe the qiqqa library isn't removed upon uninstall...

I still haven't updated my home machine's Qiqqa to the latest version, since it works fine. Let me know if doing so would be beneficial for diagnostics.

Cheers again bud!

@GerHobbelt
Copy link
Collaborator

GerHobbelt commented Oct 29, 2020

Thought: could it be that the database file has some form of machine-specific ID that leads it to be readable on the machine that set it up, but not on other machines?

Not that I recall.

Besides, the .s3db file is a plain Sqlite database file and those are portable across machines as far as I know. (Since Qiqqa only runs on Windows, it's even simpler: every machine will then be little endian and 32-bit execution for Qiqqa runs as a 32-bit .NET application, even when the OS is 64-bit, so I cannot imagine anything that might make it load on one and fail on the other. (Aside: This 32-bittiness is due to the embedded webbrowser (XULrunner) forcing the whole application down to 32-bit exec alas.)

Uninstalled & reinstalled Qiqqa on work machine. Upon reopening, my intranet library is present (with 0 docs as usual). This seems strange; maybe the qiqqa library isn't removed upon uninstall...

Indeed, Qiqqa does not delete user config upon install: that's a safety measure so folks don't 'loose' their Qiqqa libraries when upgrading.

The magic ingredient there is the file listing the discovered libraries, which sits in the libraries base directory: Qiqqa.known_web_libraries -- NOTE that when you had "Web Libraries" back in the day of commercial Qiqqa or otherwise mixed & mashed your library collection, then you may discover there are multiple files called Qiqqa.known_web_libraries in the various subdirectories of the Qiqqa base dir: all of these are loaded and combined into a single lump sum set at Qiqqa start of application.

I still haven't updated my home machine's Qiqqa to the latest version, since it works fine. Let me know if doing so would be beneficial for diagnostics.

Might be useful later, but hold off for a bit as I'm working on a new release which should be ready tomorrow there-abouts.

Besides, the .s3db file (and the rest) SHOULD BE cross-version binary compatible with all v79/v80/v81/v82 Qiqqa releases: I haven't changed the formats of any (yet). 😄

Consequently my expectation had been that your Qiqqa setups should either yak about the .s3db database file both, or be able to read & write it without errors.

🤔 🤔 🤔 🤔

Given the results so far and the (to me) very curious behaviour as you describe, let me back-pedal and make darn sure we're on the same page about your layout:

  • you have two work machines:
    • one I will call HOME
    • another one I will call OFFICE
  • Qiqqa runs on both
  • both HOME and OFFICE machines have access to the same NAS storage:
    • this is addressed as a UNC path: '\\NAS\Si Work\Papers & Books\QiqqaSync\Qiqqa.LibraryMetadata.s3db'
    • both at HOME and at the OFFICE, the Qiqqa library is configured to sync with that UNC path

That last point can only be easily checked with the Qiqqa version that you got from me, as previous versions didn't yet show the sync path in the Sync Management dialog.

Anyway: is the above HOME/OFFICE/NAS layout assumption correct? (If not, please correct me!)


There's one more thing you might want to check, just in case:

The 'sync target' (in your case the NAS directory) should also contain a file called Qiqqa.LibraryDetail.txt: you can open that file in a text editor, e.g. Notepad++ to have a look.

This is one example how such a file should look:

{"Id":"INTRANET_FFFF9774-FFFF-FFFF-FFFF-E67433F7FFFF",
"Title":"Issue 142 Library #1 for Qiqqa",
"Description":"yada yada yada."}

The exact format is quite liberal (whitespace & newlines don't matter) as this is a JSON format file.

The important bit is the Id: this is the exact name of the directory your library should be stored in on both machines.

For example, if your Qiqqa base directory on HOME would be (like I have):

  G:\Qiqqa\base\

then the library from the example should be in

  G:\Qiqqa\base\INTRANET_FFFF9774-FFFF-FFFF-FFFF-E67433F7FFFF\

so you should find the library database file there, at least:

  G:\Qiqqa\base\INTRANET_FFFF9774-FFFF-FFFF-FFFF-E67433F7FFFF\Qiqqa.library

Same for the OFFICE machine, where I'll say, for this example, the base directory is at

  C:\Users\Ger\Documents\Qiqqa\

hence the same library there should be in

  C:\Users\Ger\Documents\Qiqqa\INTRANET_FFFF9774-FFFF-FFFF-FFFF-E67433F7FFFF\

with its own local library database file (and other data):

  C:\Users\Ger\Documents\Qiqqa\INTRANET_FFFF9774-FFFF-FFFF-FFFF-E67433F7FFFF\Qiqqa.library

So far, that's the only other thing I can imagine that may have occurred somehow, is one of the machines (OFFICE?) losing the sync target reference.

Do note that I'm grabbing at straws here as I have no good explanation for what's happening over at yours, so this will take some diagnosing iterations before we hit it. 😢

That's worst case scenario and the reason why I requested you back up everything: when we don't know what's going on precisely, stuff can get worse before we get it fixed!

Let me know if that Qiqqa.LibraryDetail.txt cross-check delivered anything or my layout assumptions of your situation are wrong.

Stay tuned for another Qiqqa setup tomorrow. (Will be late-ish as this diagnostics round uncovered other bad bits in testing here locally, which are getting fixed.)

@SimonDedman
Copy link
Author

SimonDedman commented Oct 30, 2020

Hi again,

My layout is exactly as you described, yes.

My Qiqqa.LibraryDetail.txt contains only the line:

{"Id":"INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73","Title":"SimonDedmanNASsync","Description":"Synced in NAS work papers folder"}

On my HOME machine:

C:\Users\simon\AppData\Local\Quantisle\Qiqqa\INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73

On my WORK machine:

C:\Users\simon\AppData\Local\Quantisle\Qiqqa\INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73

Ok, so, same. But obviously the WORK machine's folder has a lot less in it, 5kb vs 4.5gb.

Maybe if I again uninstall qiqqa on WORK, AND delete the user config files??

Edit: I "Forgot" the intranet library on WORK and it did NOT delete that folder (C:\Users\simon\AppData\Local\Quantisle\Qiqqa\INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73). So I manually moved the folder, restarted Qiqqa, joined the intranet library at NAS again, same issue.

20201030010202:code = CantOpen (14), message = System.Data.SQLite.SQLiteException (0x800007FF): unable to open database file
at Qiqqa.DocumentLibrary.IntranetLibraryStuff.IntranetLibraryDB.GetIntranetLibraryItemsSummary()
at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder_Intranet.BuildFromRemote(Library library, SynchronisationStates& synchronisation_states)
at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder.BuildFromRemote(Library library, SynchronisationStates& synchronisation_states)
at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder.Build(Library library, Dictionary`2 historical_sync_file)
at Qiqqa.Synchronisation.BusinessLogic.LibrarySyncManager.SynchronizeMetadata_INTERNAL_BACKGROUND(Library library, Boolean restricted_metadata_sync, Boolean is_readonly)

The folder has been created afresh. Possibly deleting the full user config files folder will work though, I'll give it a whirl.

Edit: still no. It does clean out some memories of configurations but the issue remains. The folder is created, again with the correct looking name. The mystery continues!

@GerHobbelt
Copy link
Collaborator

Quick prelim release for you to try out: https://github.com/GerHobbelt/qiqqa-open-source/releases/tag/v82.0.7578.6369

When you install this one on both machines, it should present the proper Sync Point path ('\\NAS\Si Work\Papers & Books\QiqqaSync\Qiqqa.LibraryMetadata.s3db') as desired -- since you have still trouble with the OFFICE machine, this should be able to check my current working assumption that something on the OFFICE box corrupted/killed the Sync Point setting.

@SimonDedman
Copy link
Author

Strange - no change in the path having upgraded the office machine only (so far):
qiqqaNasSync2

Log attached.
Qiqqa-20201031.221242.log

@GerHobbelt
Copy link
Collaborator

Strange indeed. Will check your logfile in a bit -- just finishing other stability work on Qiqqa (#264 + the aftermath of 0d35bf6).

@GerHobbelt
Copy link
Collaborator

Okay. The magic ingredient in that one is this chunk:

20201031.221346 [Q] ERROR [22] [20.369M] IntranetLibraryDB::GetItemsSummary: Database I/O failure for DB '\\NAS\Si Work\Papers & Books\QiqqaSync\Qiqqa.LibraryMetadata.s3db'.

System.Data.SQLite.SQLiteException
Message: unable to open database file
ErrorCode: 0x0000000E
HResult: 0x800007FF
Source: System.Data.SQLite
StackTrace:    at System.Data.SQLite.SQLite3.Open(String strFilename, String vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool)
   at System.Data.SQLite.SQLiteConnection.Open()
   at Qiqqa.DocumentLibrary.IntranetLibraryStuff.IntranetLibraryDB.GetIntranetLibraryItemsSummary()
TargetSite: Void Open(System.String, System.String, System.Data.SQLite.SQLiteConnectionFlags, System.Data.SQLite.SQLiteOpenFlagsEnum, Int32, Boolean)

20201031.221346 [Q] INFO  [22] [20.006M] About to display client stats: Something unexpected has happened, but it's okay. unable to open database file
20201031.221349 [Q] INFO  [Main] [24.656M] Screen position for window UnhandledExceptionBox stored as 1400|400|640|600|Normal
20201031.221349 [Q] ERROR [22] [24.738M] Unhandled Exception Handler: Something unexpected has happened, but it's okay. unable to open database file - You can continue working, but we would appreciate it if you would send us some feedback on what you were doing when this happened.

System.Data.SQLite.SQLiteException
Message: unable to open database file
ErrorCode: 0x0000000E
HResult: 0x800007FF
Source: System.Data.SQLite
StackTrace:    at Qiqqa.DocumentLibrary.IntranetLibraryStuff.IntranetLibraryDB.GetIntranetLibraryItemsSummary()
   at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder_Intranet.BuildFromRemote(Library library, SynchronisationStates& synchronisation_states)
   at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder.BuildFromRemote(Library library, SynchronisationStates& synchronisation_states)
   at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder.Build(Library library, Dictionary`2 historical_sync_file)
   at Qiqqa.Synchronisation.BusinessLogic.LibrarySyncManager.SynchronizeMetadata_INTERNAL_BACKGROUND(Library library, Boolean restricted_metadata_sync, Boolean is_readonly)
TargetSite: Void Open(System.String, System.String, System.Data.SQLite.SQLiteConnectionFlags, System.Data.SQLite.SQLiteOpenFlagsEnum, Int32, Boolean)

So the machine is telling us it cannot read the .s3db file. At all, since it's not bad records bubbling up from a query, which would look quite different with the bleeding edge of Qiqqa as you have now running.

That does, regrettably, not tell us yet why it finds the thing 'cannot be opened'. To help us diagnose that, I fear I'll have to do a bit more work on the code so Qiqqa can tell us a bit more about the why. Stay tuned for a new setup installer coming your way today.

GerHobbelt added a commit to GerHobbelt/qiqqa-open-source that referenced this issue Nov 1, 2020
- when an SQLite error occurs, a full diagnostics report is included in the logfiles for further diagnosis by the user and/or engineer.
  + this is applied to both local database files (`*.library`)and the 'Sync Point' (`*.s3db`) to help diagnose jimmejardine#257 and similar.
- dialed the Sqlite diagnostics up: Turn on extended result codes via `connection.SetExtendedResultCodes(true);`
- Library integrity checks dialed up several notches: report and track data corruption in the log and pop an alertbox for user to decide to either abort the application or continue as-is -- which should be reasonably safe... - done the same on the Sync Point/Share Target side! .s3db is now integrity-checked on access.
- disambiguated a few confusing log lines.
- quite a bit of work done on metadata record recovery from corrupted/botched/hand-edited SQLite databases (like the ones I still have around from the time of the bad days of Commercial Qiqqa v76-v79, which led to: )
  - some records can be recovered in a way as to treat them as pure BibTeX; adding the fingerprint from the first column as needed.
  - the above is a THIRD option for recovering the metadata and is useful when older databases have been touched by external Sqlite tools: it turns out the previous Qiqqa code did not behave well when a BLOB field was changed in subtle ways by these external tools, including the SQLite CLI itself.
- stop yakking about 'don't know how to yada yada' for libraries which landed in the sync list but do not have a Sync Point: these libraries are now *ignored* (but reported in the log, in case sync was intended and we have a very obscure failure on our hands, e.g. jimmejardine#257 )
- add developer JSON5 option "BuildSearchIndex" to shut up and cut off the Lucene index building/updating background task. This was/is important as we're hitting the very limit of 32-bit memory with Qiqqa while testing with 30+ LARGE old databases in various states of disrepair: at a grand total of 200K+ PDF records, it looks like some re-indexing action will quickly drive us into 'Out Of Memory' fatal failure, while we test for other matters and are NOT interested in the index per se, right now.
- LoadFromMetaData(): add addition sanity check to WARN in log about record key/document fingerprint NOT matching the fingerprint stored in the metadata BLOB. (This should be a RARE error, but indicative of DB data corruption / manual patching and important for diagnosis in your own log files.)
- killed a couple of (even cycling!) 'unhandled exception' dialogs: these buggers are useless when we're already shutting down the app and should therefor only dump the error report in the log.
- correction for the 'end of life of application run' checks and consequent log shutdown.

An overall stability improvement!
@GerHobbelt
Copy link
Collaborator

Here's the new version to test for you: https://github.com/GerHobbelt/qiqqa-open-source/releases/tag/v82.0.7579.33985

Of particular interest to you & me in this case would be the new diagnostic report appended to every SQLite error: there we should find all available File System info plus a few tests and some preliminary diagnosis of the situation as done by Qiqqa itself.

It'll all end up in the log files, so, as before, I am mighty curious to hear what the OFFICE machine has to say re NAS access now.


P.S. note that I will have the day job to attend to the entire week, so things may get delayed or late as working hours are 0700-2200 or there-abouts inc. travel (remote real estate project). I'll try to look into anything you send ASAP anyway. Mighty curious what the heck is going wrong.

@SimonDedman
Copy link
Author

Cheers mate, attached. Of interest based on my uneducated eye:
"Could not find file 'C:\Users\simon\AppData\Local\Quantisle\Qiqqa\INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73\Qiqqa.sync_md5'."
Maybe normal on first sync attempt?

"--> Is a normal file: False"
Not sure if this is good or bad!

"SQLite Error Code: 14
Reported error code is NOT a SQLite Extended Error Code.
SQLite HResult: -21474816018:X"

"--> VERDICT OK(?): this DOES look like a very normal file."

Strange...

Ger, absolutely ZERO need to explain nor apologise for delays buddy - I appreciate you're doing this in your spare time as a gift to the community and specifically for me (currently). Day job takes precedent, always, of course. Enjoy the travel - seems like a very unusual thing nowadays!

Cheers.

Qiqqa-20201102.173708.LOG

@GerHobbelt
Copy link
Collaborator

GerHobbelt commented Nov 2, 2020 via email

@GerHobbelt
Copy link
Collaborator

(off-topic: doing this in the github issue tracker via web as I want the formatting to be just-right or this will become a horrible read. Back to the subject at hand: analysis of the latest logfile and replying to your notes:)

OFFICE log:

the important stuff starts with this:

20201102.173824 [Q] INFO  [Main] [26.720M] Syncing
20201102.173824 [Q] WARN  [Main] [27.308M] SYNC IGNORE: library 'Library Guest: Local Guest Library' has no Sync Point a.k.a. Share Target set and thus cannot be synced.

Sync process is starting. 'Guest' lib is classically now syncable, no surprises there. (This will change in a future release, but we'll stick with what we have right now.) So far, this is all 'good noises'. Expected output. Onwards!

20201102.173824 [Q] DEBUG [6] [27.317M] SYNC_META:INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73:Starting sync of SimonDedmanNASsync (0/0: 0.0%)
20201102.173824 [Q] INFO  [6] [27.317M] Syncing metadata for SimonDedmanNASsync
20201102.173824 [Q] DEBUG [6] [27.325M] SYNC_META:INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73:Loading sync history (0/0: 0.0%)

Qiqqa inspecting your second library on the OFFICE box. This is the one that comes with a Sync Point (we'll see in a sec). So far, good noises. All clear.

20201102.173824 [Q] WARN  [6] [27.958M] Error loading C:\Users\simon\AppData\Local\Quantisle\Qiqqa\INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73\Qiqqa.sync_md5
System.IO.FileNotFoundException
Message: Could not find file 'C:\Users\simon\AppData\Local\Quantisle\Qiqqa\INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73\Qiqqa.sync_md5'.
HResult: 0x80070002
Source: mscorlib
StackTrace:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Utilities.Files.SerializeFile.Load(String filename)
   at Utilities.Files.SerializeFile.LoadRedundant(String filename)
   at Utilities.Files.SerializeFile.LoadSafely(String filename)
TargetSite: Void WinIOError(Int32, System.String)

Error. About the local .sync_md5 file.
WITHOUT CONTEXT, I would have said "not a problem. That's just indicative of a lib with sync point which has never been synced yet on that machine." (Hold that thought for a sec...!) Qiqqa 'agrees' with my assessment, as we see in the next log line:

20201102.173824 [Q] INFO  [6] [27.968M] There is no sync history, so creating a new one

Again, 'good noises', IF IT WEREN'T for me wondering aloud: "but Simon has had this setup for a while now! Did he nuke the sync_md5 on the OFFICE previously? (Which is A-okay, Qiqqa should just pick from there and do a full sync on OFFICE, but this is me right now wondering if you did this as part of the ongoing process (might have mentioned to you to do this a while ago) or if this also a 'surprise' to you.

If it is a surprise to you, this merrits a "what the heck?" but otherwise won't be able to help us fix the situation. The actions mentioned in my previous message might resolve the matter. So all we can do now with this is raise eyebrows, wonder and continue with the rest of the logfile:

20201102.173824 [Q] DEBUG [6] [27.977M] SYNC_META:INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73:Building sync state from local history (0/0: 0.0%)
20201102.173824 [Q] DEBUG [6] [27.977M] SYNC_META:INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73:Building sync state from local files (0/0: 0.0%)
20201102.173824 [Q] DEBUG [6] [28.001M] SYNC_META:INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73:Building sync state from Web/Intranet Library (0/0: 0.0%)

That's the sync process starting for real. Just did a quick source code check about those (0/0: 0%) numbers: that's just internal progress counters and we're at the start, knowing nothing yet, so 0/0 is fine.
Good noises. Onwards.

20201102.173824 [Q] ERROR [6] [23.221M] IntranetLibraryDB::GetLibraryItemsSummary: Database I/O failure for DB '\\NAS\Si Work\Papers & Books\QiqqaSync\Qiqqa.LibraryMetadata.s3db'.

System.Data.SQLite.SQLiteException
Message: unable to open database file
ErrorCode: 0x0000000E
HResult: 0x800007FF
Source: System.Data.SQLite
StackTrace:    at System.Data.SQLite.SQLite3.Open(String strFilename, String vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool)
   at System.Data.SQLite.SQLiteConnection.Open()
   at Qiqqa.DocumentLibrary.IntranetLibraryStuff.IntranetLibraryDB.GetIntranetLibraryItemsSummary()
TargetSite: Void Open(System.String, System.String, System.Data.SQLite.SQLiteConnectionFlags, System.Data.SQLite.SQLiteOpenFlagsEnum, Int32, Boolean)

Kaboom! There's that one again. Bad noise! We already know this, but this SQLite barfing a hairball about not being able to connect (not even running a query yet!) to the NAS DB: the s3db file.

Your bleeding edge Qiqqa software now adds a diagnostic report, which we'll get into next:

20201102.173830 [Q] ERROR [6] [27.420M] --- Diagnosis for reported problem ---
======================================

--> File Attributes:                                Archive

'Archive' attribute. FileSystem legacy stuff from back in the olden days of MSDOS. Almost nobody does anything with that flag, anymore. Qiqqa and SQLite sure wouldn't bother about it being off or on.

Here follows the rest of the detailed FileSystem info dump which I included in the diagnostics report.

--> File Creation Date (UTC):                       29/10/2020 19:16:44
--> File Last Changed Date (UTC):                   29/10/2020 19:34:57
--> File Last Access Date (UTC):                    29/10/2020 19:34:58
--> Is marked as READ ONLY:                         False
--> Is marked as OFFLINE:                           False
--> Is marked as archived:                          True

(Last one: that's the archive bit again. Just from another API. ok.)

--> Is marked as HIDDEN:                            False
--> Is a SYSTEM FILE:                               False
--> Is encrypted by the operating system:           False
--> Is compressed by the operating system:          False
--> Is a mount point:                               False
--> Is temporary:                                   False
--> Is a symbolic link:                             False
--> Is a sparse file:                               False
--> Is a reparse point:                             False
--> Is not content indexed by the operating system: False
--> Is a directory:                                 False
--> Is a device:                                    False

Nothing crazy so far. "Vanilla". Good noises.

--> Is a normal file:                               False

This one may indeed sound confusion, but it his is the OS telling us that the file is a 'normal file' without any attributes set. Since the (A)=Archive bit has been set, this is reported as "normal=false" at OS level, but nothing crazy or off about this. So, confusion aside, definitely not surprising to me.

I should have written this one up as "file without any attributes set" to prevent confusion. Good catch in your notes. Anyway, no cause for concern.

--> File size:                                      27233280 bytes

First time we see the size: this is straight off the disk from the Windows operating system: this is the number you'ld see in the Windows Explorer when you request the File Properties of the s3db file. All okay.

--> Successfully scanned the entire file: length scanned = 27233280 bytes

THIS is important as under hood that was me just READING every byte in the s3db file from NAS: this means that the file proven to be readable by the Qiqqa software, at least at a binary level!

Meanwhile Qiqqa's built-in SQLite kicks up a ruckus, so from this (plus the next line in the log!), it looks like there's some trouble for SQLite about the database file not being in the correct format? Or is SQLite.NET doing things I don't know yet? I downloaded their sourcecode, but that quite a large chunk of code and I haven't had time to dig through that bunch yet, but this part of the diagnostic tells me Qiqqa can read the s3db, so, following logic, it must therefor be something in the format OR in yet-unidentified problems originating from the exact way SQLite opens a database file. We'll have to dig deep to answer that one. (Incidentally, this is why I refuse to work on projects with closed-source libraries: we you cannot read the sourcecode in cases like this, you've hit a very hard wall. There's a commercial crypto-library way back which cost me dearly in reverse-engineering/diagnostics cost (2 man-weeks of digging with sophisticated rev-eng tools) thanks to closed-source. Anyway, we'll have to dig into SQLiteNET if we want to get to the bottom of this, because my new diagnostics just completely the normal FILE READ process and found no fault what-so-ever: "Successfully scanned the entire file: length scanned = 27233280 bytes": no error report in this line, size reported MATCHES the OS-reported filesystem property 'size' from the previous line. As one would expect for any 'normal' file...

--> Successfully opened the file for WRITE ACCESS

Now that line was added by me as my diagnostics code goes through the motions at OS level to open the s3db file for WRITING instead of only READING. The OS just told us: "fine. here you go. Do your thing."

Nevertheless, SQLiteNET comes back with "unable to open database file" so somebody is pulling my leg and all parties point at SQLiteNET by now... We'll have to investigate that one further, alas.

    As this report is about a SQLite database error, it MAY be useful to search
    the Internet for generic help and/or discussion of the reported SQLite error:

    ( ref: https://sqlite.org/rescode.html )
    ( ref: https://sqlite.org/c3ref/c_abort.html )
    SQLite Error Code: 14
    Reported error code is NOT a SQLite Extended Error Code.
    SQLite HResult: -21474816018:X

This is me and my diagnostics report code telling us that SQLiteNET (which, you'll see below, has been configured to output the most elaborate set of errors possible: SetExtendedResultCodes(true)) is bluntly returning a very generic error code: number 14. (The HResult is the translation of that one, where my diagnostics report code has a integer-to-hexadecimal-string-representation conversion bug, which has to be fixed, but only relevant insofar as to fix the -21474816018:X bogus output (something about signed 32 integers and unsigned values, yada yada yada). This number is printed earlier in the log file as 0x800007FF, which does not help us any further than the SQLiteNET error code '14'.

Given the report output, we also know that SQLiteNET didn't deem this worthy of additional error info: 'NOT a SQLite Extended Error Code'. So 'unable to open database file' is about all the information we get for this. Bugger. RTFC is in order to discover why. (RTFC=Read The F****** Code; geek-speak for if you want to know what's going down, the source code is your only chance. Very dark. So real. 😄

Let's have a look if there's more to learn from the log:

      SQLite: the define constants (i.e. compile-time options): INTEROP_EXTENSION_FUNCTIONS INTEROP_FTS5_EXTENSION INTEROP_JSON1_EXTENSION INTEROP_PERCENTILE_EXTENSION INTEROP_REGEXP_EXTENSION INTEROP_SESSION_EXTENSION INTEROP_SHA1_EXTENSION INTEROP_TOTYPE_EXTENSION INTEROP_VIRTUAL_TABLE NET_46 PRELOAD_NATIVE_LIBRARY THROW_ON_DISPOSED TRACE TRACE_PRELOAD TRACE_SHARED TRACE_WARNING USE_INTEROP_DLL USE_PREPARE_V2 WINDOWS
      SQLite: the underlying SQLite core library: 3.32.1
      SQLite: SQLITE_SOURCE_ID: 2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba83350
      SQLite: the compile-time options: COMPILER=msvc-1900 ENABLE_API_ARMOR ENABLE_COLUMN_METADATA ENABLE_DBSTAT_VTAB ENABLE_FTS3 ENABLE_LOAD_EXTENSION ENABLE_MEMORY_MANAGEMENT ENABLE_PREUPDATE_HOOK ENABLE_RTREE ENABLE_SESSION ENABLE_STAT4 ENABLE_STMTVTAB MAX_ATTACHED=30 SOUNDEX THREADSAFE=1 USE_URI WIN32_MALLOC
      SQLite: the version of the interop SQLite assembly: 1.0.113.0
      SQLite: the unique identifier for the source checkout used to build the interop assembly: 1911e60e5ee59d01f841dbe35dfd8e5104eae8c8 2020-05-30 14:28:05 UTC
      SQLite: the compile-time options used to compile the SQLite interop assembly: CODEC EXTENSION_FUNCTIONS JSON1_EXTENSION PERCENTILE_EXTENSION REGEXP_EXTENSION SESSION_EXTENSION SHA1_EXTENSION TOTYPE_EXTENSION VERSION_NUMBER=3032001 VIRTUAL_TABLE
      SQLite: the version of the managed components: 1.0.113.0
      SQLite: the unique identifier for the source checkout used to build the managed components: 1911e60e5ee59d01f841dbe35dfd8e5104eae8c8 2020-05-30 14:28:05 UTC
      SQLite: the extra connection flags: None
      SQLite: the default connection flags: Default

All that stuff is me dumping every version number or other release markers I can get my grubby paws on to help me investigate if possibly maybe there's a DLL gone sideways or other installed software crap happenin'. Here? No problem at all. Clean as a whistle. All numbers match the ones on my dev box and are what your Qiqqa installer installed. No surprises there. Good noises.

      (ref: https://sqlite.org/c3ref/extended_result_codes.html )
      SQLite Extended Error Reporting has been ENABLED: SetExtendedResultCodes(true)
---------

That's just me telling folks that this SQLite has been specifically told to turn on advanced error reporting via the API it has provided for that. Nothing special. Just added in the very last release you got from me.

Onwards.

--> VERDICT OK(?): this DOES look like a very normal file.

That is me combining a few of the geeky bits about the file and saying "this is about what I expect to see at OS level for a file that Qiqqa might be working on". As you noted, here's that "normal" again, but this time it is me with my perspective, instead of a deep Windows API with a very specific, different perspective of what's "normal".

Hence this is fine and leads me to conclude that the problem is somewhere hiding in the internals of SQLiteNET (or even SQLite itself!) and I have to find out what might be other reasons for SQLite to dump an error 14 "cannot open" in my lap on one machine, while another does just fine.

I allude that, very indirectly, in the next bit of the logfile:

    HOWEVER, it may have incorrect a.k.a. 'corrupted' content, which made Qiqqa barf,
    or there's something else going on which this simply diagnosis routine
    is unable to unearth.

    Please file a report at the Qiqqa issue tracker and include this logging
    for further inspection.

==================== End of diagnostics report ============================================

For completeness, there's also question what Qiqqa has to say about the sync process after this just happened. So let's pick out the relevant bits of the rest of the log and read those:

20201102.173830 [Q] ERROR [6] [27.495M] Unhandled Exception Handler: Something unexpected has happened, but it's okay. unable to open database file - You can continue working, but we would appreciate it if you would send us some feedback on what you were doing when this happened.

System.Data.SQLite.SQLiteException
Message: unable to open database file
ErrorCode: 0x0000000E
HResult: 0x800007FF
Source: System.Data.SQLite
StackTrace:    at Qiqqa.DocumentLibrary.IntranetLibraryStuff.IntranetLibraryDB.GetIntranetLibraryItemsSummary()
   at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder_Intranet.BuildFromRemote(WebLibraryDetail web_library_detail, SynchronisationStates& synchronisation_states)
   at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder.BuildFromRemote(WebLibraryDetail web_library_detail, SynchronisationStates& synchronisation_states)
   at Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder.Build(WebLibraryDetail web_library_detail, Dictionary`2 historical_sync_file)
   at Qiqqa.Synchronisation.BusinessLogic.LibrarySyncManager.SynchronizeMetadata_INTERNAL_BACKGROUND(WebLibraryDetail web_library_detail, Boolean restricted_metadata_sync, Boolean is_readonly)
TargetSite: Void Open(System.String, System.String, System.Data.SQLite.SQLiteConnectionFlags, System.Data.SQLite.SQLiteOpenFlagsEnum, Int32, Boolean)

20201102.173830 [Q] INFO  [6] [22.635M] About to display client stats: Something unexpected has happened, but it's okay. unable to open database file

That's the code in Qiqqa catching that SQLite error, uttering some noises but nothing extra useful.

From this we at least know that Qiqqa hasn't given up the ghost entirely, so we should see some more sync noises in the log...

20201102.173956 [Q] DEBUG [6] [25.951M] SYNC_META:INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73:Saving sync history (0/0: 0.0%)
20201102.173956 [Q] INFO  [6] [26.961M] Getting list of documents in Intranet Library \\NAS\Si Work\Papers & Books\QiqqaSync
20201102.173958 [Q] INFO  [6] [25.380M] Got LOCAL list of documents (1873) in Intranet Library \\NAS\Si Work\Papers & Books\QiqqaSync
20201102.173958 [Q] INFO  [6] [25.627M] Downloading documents for SimonDedmanNASsync
20201102.173958 [Q] INFO  [6] [25.627M] Queueing 0 PDF download requests.
20201102.173958 [Q] DEBUG [6] [26.421M] SYNC_META:INTRANET_0E4255D5-3AFB-4522-BDD4-74E0E5C23A73:Finished sync of SimonDedmanNASsync (0/0: 0.0%)

That last line is indeed Qiqqa telling us it's now done with SYNC of the SimonDedmanNASsync library: nothing on the remote side, a DB error at the start of that process, so nothing that can be done. Hence no mention of files or records processed. Expected, yet undesired.

However, a possibly fun fact are the log lines before that one: that's ANOTHER library of yours, as far as I can tell ('QiqqaSync' instead of 'SimonDedmanNASsync') being synced successfully!? So the error seems very specific to a single library in a larger set, or am I reading this wrong?

Anyway, like I said before: the plot thickens and I'll need to dig into SQLiteNET to maybe find out what's going on for real.

Meanwhile, I hope you have a spot of luck with Action 2 (RENAME/DELETE s3db + sync_md5 files, reconstructing the sync that way). Keep me posted and thanks for hanging in there!) 👍

20201102.173958 [Q] INFO  [32] [26.822M] +Saving known Web Libraries to C:\Users\simon\AppData\Local\Quantisle\Qiqqa\Guest\Qiqqa.known_web_libraries
20201102.173958 [Q] INFO  [32] [27.626M] -Saving known Web Libraries to C:\Users\simon\AppData\Local\Quantisle\Qiqqa\Guest\Qiqqa.known_web_libraries

Bit of an aside, but that Qiqqa.known_web_libraries file is where Qiqqa stores the actual Sync Point path: if anyone ever loses that file, they loose the ability for Qiqqa to 'discover' what the Sync Point is for each library and you end up with them all being flagged as local libraries only.

I'll need to do more work on this stuff. (Last weekend's slew of changes saw the old commercial Qiqqa cruft being regarding this being kicked out finally -- it's permeated through the source code. 😞 ) Folks should be able to assign or change the Sync Point of their library and point them at any NAS drive or Cloud Storage they may prefer instead to sync their libs across multiple machines. Alas, that's Future Music. right now we have a very odd Qiqqa library issue here.

I wrote this up also in hopes that maybe one day someone else has need for a bit of "how to read this verbose logfile?" re Qiqqa libraries and the underlying database technology. Let's pray it useful then. 😄

@GerHobbelt
Copy link
Collaborator

😭 Last message near the end: I'm wrong. The 'fun fact' I mention there is me not watching out carefully enough: it's the same library, only the local side of its sync process still being able to collect the set of PDFs and then saying there's nothing to do (heck, yeah, s3db remote DB could not be opened, so no sync work can be done!)

The Library name is SimonDedmanNASsync, while it's sync directory on the NAS is called QiqqaSync. That's fine.

Github allows me to EDIT my messages, but I'll the above last message as it is; if I turn this in a document, that 'fun fact' paragraph (and question) should be scratched as it's completely wrong.

Time to spin down here. Catch some Z's. 😴 😴

Best of luck with Action 2 (and 1 too, of course) and let me know how it goes.

@SimonDedman
Copy link
Author

SimonDedman commented Nov 3, 2020 via email

@SimonDedman
Copy link
Author

SimonDedman commented Nov 5, 2020

Hi bud,
Right, working through this now,

  1. sqdb file just emailed to you

  2. /A/B. backup everything then rename Qiqqa.LibraryMetadata.s3db & sync from HOME mechine to have it rebuild the s3db: just done. I did this a few weeks ago, and it works flawlessly. HOME is back to normal.

  3. In OFFICE: Forget intranet library in Qiqqa, delete that folder in /Quantile/Qiqqa/ (inc sync.md5). Reopen qiqqa, join intranet library, full sync. Oddly when I join intranet library, I'm then greeted with a blank Home screen:
    image

Nonetheless, manually open intranet library from the menu, sync details,
image

Start sync: same issue:
image

Log attached.
Qiqqa-20201105.015324.LOG

The confusion continues! :)

Cheers mate

@GerHobbelt
Copy link
Collaborator

GerHobbelt commented Nov 5, 2020 via email

@SimonDedman
Copy link
Author

Potentially related: since installing the older pre-release version I noticed my watch folder wasn't present. When I go to add it again, the NAS isn't present in Network, in the folder browser. But it's present & open & I'm editing files within it using Windows Explorer:
image

Not sure why this would be, I'll restart to see if that helps, but this might be a clue regarding Qiqqa's problems connecting to the NAS sync library...

@SimonDedman
Copy link
Author

Actually, looks like windows doesn't see the NAS now. Joy. Edit: fixed. Windows decided to turn SMB CIFS off, on a whim. Jerk OS.

@SimonDedman
Copy link
Author

SimonDedman commented Apr 5, 2021

Re blank PDFs, I have this now on a recent paper:
image

Page 6 is blank, but has a normal thumbnail and the text seems to be indexed since it shows up in searches.

Edit: and then some minutes later it appears. Really odd.

@GerHobbelt
Copy link
Collaborator

GerHobbelt commented Apr 7, 2021 via email

@SimonDedman
Copy link
Author

@SimonDedman
Copy link
Author

Hi bud, related to this, I've noticed that the watch folder is missing when I open Qiqqa. That folder is on the NAS also, so it may be that Qiqqa can't connect to it quickly enough and gives up and then deletes the folder location in its settings?

@GerHobbelt
Copy link
Collaborator

GerHobbelt commented Apr 8, 2021 via email

GerHobbelt added a commit to GerHobbelt/mupdf that referenced this issue May 20, 2021
…or Qiqqa Sync and further investigation of jimmejardine/qiqqa-open-source#257, jimmejardine/qiqqa-open-source#319, ...)

- discarded the unsupported luratech projects
- discarded the Artifex/mupdf wix installer project; going to use inno setup for that
- added another portion of the owemdjee libraries as MSVC projects -- just plonked the source files in there, did some very rudimentary setup/config work, so don't expect those to compile & run yet. This is about getting them into MSVC and towards building together as a unit.
GerHobbelt added a commit to GerHobbelt/lib_nas_lockfile that referenced this issue May 20, 2021
… Qiqqa Sync and further investigation of jimmejardine/qiqqa-open-source#257, jimmejardine/qiqqa-open-source#319, ...)

- Wrote the basic lockfile primitives
- Got a start with Google Test to create a unit test set for this: it's too important to get it right to NOT do unit tests for this.
GerHobbelt added a commit to GerHobbelt/qiqqa-open-source that referenced this issue Jun 2, 2021
…mitives for Sync: lib_nas_lockfile. TODO: additional tools for performing the new Sync concept and testing viability on multiple platforms.
GerHobbelt added a commit to GerHobbelt/mupdf that referenced this issue Jun 2, 2021
…k file locking primitives for Sync: lib_nas_lockfile. TODO: additional tools for performing the new Sync concept and testing viability on multiple platforms.
GerHobbelt added a commit to GerHobbelt/owemdjee that referenced this issue Jun 2, 2021
…k file locking primitives for Sync: lib_nas_lockfile. TODO: additional tools for performing the new Sync concept and testing viability on multiple platforms.
@GerHobbelt
Copy link
Collaborator

Just a couple of notes-to-self re this issue - still unsolved 😢 :

Talked to someone today (off net, RL) who had tangled with quite similar issues regarding mapped network drives. His problems revolved around non-working MSAccess applications. Environment included BSD servers with Samba (SMB) over VPN and other environments.

  • The final bit he needed was to add the network path to the Trusted Locations in the registry. --> checked this out, but AFAICT that only applies to Office applications and we are not an MSOffice application, so those registry entries (and policies) should not be relevant. Noting them here anyway, so I can tick them off the list as "looked at" when I run into them again.

  • Other problem reported by him: network mapped paths would not be accessible at (user) machine startup until the user physically clicked in windows Explorer to open the mapped drive. Nothing else worked and he couldn't give a ticket reference but told me this happened a few years ago when the company switched their floor machines from XP to Windows 7. The problem appeared to occur with Vista and later (7, 8, 10) and was, reportedly, flagged by an MS rep as "won't fix". He solved it by writing a startup script which would poll to check if the drive was known already (after boot + login this would also take a random time and was hurdle 1), then it would attempt to look in the mapped drive using a DOS-style DIR command until that succeeded, which could take several more minutes before success, then he would check & reset those Trusted Locations registry entries (which would be erased by MS on Patch Tuesdays and arbitrary system updates), then he would run a sample MSAccess app which was written to report database I/O success/fail and quit -- put that app in a poll loop until success, and only then flagged the system as "ready" by starting the real MSAccess application used by the end user. SOP for users mentioned this as "login and click icon XYZ first thing in the morning, before you grab a coffee"

  • other probably related material (as our own issue reports itself as SQLite error 14 -- unresolved):

@GerHobbelt
Copy link
Collaborator

❗ Oh, note-to-self about comment just above: check out the SQLite pragma comments once you get mupdf+sqlite C/C++ backend going: then we can test those and check them in relation to network I/O.

@SimonDedman
Copy link
Author

Hey bud, happy winter. Have you had any further success with the MuPDF implementation? I'm basically unable to use Qiqqa at the moment because every pdf I open is blank. When I reopen qiqqa to that pdf, I get a blank or blurry first page and nothing else:

image

If I scroll away and come back, it's blank. If I close & reopen the pdf, blank. Looks like I'm using v82s; I think I rolled back due to other issues in other issue threads. But now I'm only making updates/edits/imports to Qiqqa at home, having given up trying to get the remote/NAS stuff working until I hear from you.

Cheers!

@GerHobbelt
Copy link
Collaborator

GerHobbelt commented Dec 10, 2021 via email

@dmitrii1204
Copy link

dmitrii1204 commented Feb 15, 2022

Hi @GerHobbelt !
First of all, I want to say that I am delighted with Qiqqa. I tested version from the site and all works fine. Now I'm trying to migrate to latest github version in order to create a library in my intranet. However, I ran into this same issue:

20220215082226:code = CantOpen (14), message = System.Data.SQLite.SQLiteException (0x800007FF): unable to open database file
in System.Data.SQLite.SQLite3.Open(String strFilename, String vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool)
in System.Data.SQLite.SQLiteConnection.Open()
in Qiqqa.DocumentLibrary.IntranetLibraryStuff.IntranetLibraryDB.GetIntranetLibraryItemsSummary()
in Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder_Intranet.BuildFromRemote(WebLibraryDetail web_library_detail, SynchronisationStates& synchronisation_states)
in Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder.BuildFromRemote(WebLibraryDetail web_library_detail, SynchronisationStates& synchronisation_states)
in Qiqqa.Synchronisation.MetadataSync.SynchronisationStateBuilder.Build(WebLibraryDetail web_library_detail, Dictionary`2 historical_sync_file)
in Qiqqa.Synchronisation.BusinessLogic.LibrarySyncManager.SynchronizeMetadata_INTERNAL_BACKGROUND(WebLibraryDetail web_library_detail, Boolean restricted_metadata_sync, Boolean is_readonly)

What do i do?

@GerHobbelt
Copy link
Collaborator

GerHobbelt commented Feb 18, 2022

FYI:

we've very recently discovered a potential cause for this sync issue (SQLite error 14, when using a NAS). More info later on Monday, but the TL;DR is this: looks like there's a very nasty issue with MS windows local caching for SMB / SAMBA network shares (which is offered by many NAS'es out of the box) in combination with SAMBA oplock (opportunistic locking) settings.

We've run into this issue in a completely different environment, not Qiqqa related, but I strongly suspect that this is cause for SQLite error 14 as well when Qiqqa attempts to sync the local database with the one located on the NAS / network-share.

This is completely random behaviour: you may experience this, or you may not. Consequences can range from the error 14 to file corruption (which is what we are investigating for a DBase4 environment ATM.)
A work-around is under test and works at the DB4 site, but I consider that work-around prone to subsequent random failures as it will impact code-flow and timing through the SAMBA code, but will not, AFAICT, truly fix or circumvent the fundamental issue.

More to follow in a few days.


TL;DR of this TL;DR: any syncing on NAS shares is at risk of error 14 SQLite errors (or worse), rarely but unpredictably and a proper solution will require fundamental changes to the Qiqqa software.

The difference being, compared to the state of affairs to date, is that at least now I have a way forward towards solving this, that gives me some confidence at being successful at least; all attempts and research to date were utterly fruitless.


The same fundamental risks/issues are expected with any drive-mapped cloud storage as well: DropBox, OneDrive, GoogleDrive, etc.
The fix under consideration right now is expected to also work out for those network/cloud solutions. Again, more news in a few days,..

@GerHobbelt
Copy link
Collaborator

Credits for SMB / SAMBA issue discovery, root cause analysis and initial work-around (disable SAMBA oplocks): @Lion251 (Henk de Leeuw).

Qiqqa will need a different approach as Qiqqa will not have full control of the SAMBA configuration nor MS Windows system settings on every site; a more rigorous fix is required for our sync issues (not just this issue #).

@dmitrii1204
Copy link

dmitrii1204 commented Feb 21, 2022

Hi @GerHobbelt !

I am very glad that you responded so quickly and despite everything, the improvement of Qiqqa continues.

I want to let you know that while I was enjoying a couple of extra days off, my colleagues solved the problem by installing an older version of v.80s.

I hope you manage to overcome this annoying issue.

@SimonDedman
Copy link
Author

Hi mate, hope you're well. Very small diagnostic element: blank page problem: Qiqqa was working fine with 3 papers open, only 2 of which I'd interacted with since opening the program, both of which are quite big. Opening another paper was blank, and then the previous papers were too. Wondering if it's a memory issue?? Or similar allocation/space kinda problem? Possibly compounded by my network setup?

TBH now I'm WFH full time I should just migrate my Qiqqa setup to the windows install and be done with the network setup...

@SimonDedman
Copy link
Author

To add to this: I jumped down a paper to the bottom, which loaded, then scrolled up and got teh blank page, and an unresponsive Qiqqa. When I minimise the window, it disappears, and seems to have crashed.

@SimonDedman
Copy link
Author

SimonDedman commented Oct 12, 2023

Hi Ger, hope you're well. I wondered if you might have any idea why something's not working for me -
I've just installed Qiqqa v80 on a windows machine, and am trying to connect to my intranet library, which is the same location as previously detailed above in this thread, \NAS\Si Work\Papers & Books\QiqqaSync

image

However this results in no papers after syncing, despite there being 8gb of stuff in that folder:

image

Any ideas why this might me? I'm connected to my NAS via RaiDrive mapping the NAS to a local folder, which I can navigate to fine in Windows Explorer.

Cheers for any ideas bud!

Edit: looks like my main Qiqqa, in Win10 in a VM, which was syncing before I believe, is now greyed out. Possible a version issue with v80?

@GerHobbelt
Copy link
Collaborator

GerHobbelt commented Oct 13, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants