Acquiring a lock on a table to be reindexed? - django

first of all, I assure you, I have googled for hours now. My main problem is that I'm trying to fix a corrupted database of the tool paperless-ngx that I'm using. I am an IT admin but I have no experience with SQL whatsoever.
I'm getting this error:
ERROR: missing chunk number 0 for toast value 52399 in pg_toast_2619
Now every guide on the entire internet (I'm gonna post this one for reference) on how to fix this tells me to REINDEX the table.
When I do this using
reindex (verbose) table django_q_task;
it keeps waiting indefinitely with this errormessage:
WARNING: concurrent insert in progress within table "django_q_task"
I am positive that there is no write happening from paperless side, all containers except for the database container have been stopped. I tried locking the table using
lock table django_q_task in exclusive mode nowait;
but the error persists. I'm at the end of my wits. I beg of you, can someone provide me with detailed instructions for someone with no postgresql experience at all?

Related

SAS with BULKLOAD=Yes: ERROR: BCP initialize error: Unable to retrieve error message

Has anyone encountered the error when trying to run in any of the bulk modes (not just bulkload=yes, but also insertbuff=xxx etc).
The related odbcbcp.dll is present in the System32 directory, so this is not the case of being unable to find it.
Runs fine w/out bulk load, but of course the speed is not even close.
SAS 9.3, Win 32-bit
Okay, with some most random luck, discovered that this may have been a bug specifically in sas 9.3, which has been subsequently eliminated in v9.4
Still an open question for those of us locked in v9.3 due to licensing.

How to avoid the "loaded.created.uncommitted" error when doing unloadAll with ember-data?

My application creates a lot of "configuration" models (ie- they only live in the app at runtime and they won't ever be persisted). I load these on demand so my app is constantly creating records and then throwing them away.
//create a record that will never be persisted
this.store.createRecord('foo', {name: 'wat'});
In the past I would just do a clear of the store but I realized this doesn't actually "remove" anything. I've decided to use the unloadAll instead
this.store.unloadAll('foo');
... but I run into this error as I have these "configuration" models
Error while loading route: Error: Attempted to handle event
unloadRecord on while in state
root.loaded.created.uncommitted.
at new Error (native)
How can I avoid this error (while still using the unloadAll as I need to truly remove these from the browser) ?
Actually this has now (should be) fixed with my PR which was merged 2 days ago:
see: https://github.com/emberjs/data/pull/1714
That PR loosens the constraint which disallowed unloading all dirty records, to disallowing only inFlight records. I believe with some time and proper thought, that constraint may also be lifted.
The rest of the PR, is specifically around proper cleanup when unloading a model, a record array, or destroying the store. I do believe this is a good first pass at proper cleanup.
I hope this (merged) PR solves your issue, if not please open a descriptive issue, and lets squash the bug.

SQL OLEDB call hanging

I've got an issue where a thread simply hangs and never returns after calling the SQL OLE DB CCommand< Taccessor, TRowset >::Open() command using the Microsoft's Active Template Library.
Here's what the call looks like:
hr = CCommand< TAccessor, TRowset >::Open( DB::Instance()->GetSession(), CComBSTR(strCmd), pPropSet, pRowsAffected, DBGUID_DEFAULT, true, 0 );
The CCommand<>::Open() method is executing a stored procedure on a SQL Server across the network.
I managed to capture a stack trace from Process Explorer, and just looking for any clues or suggestions on a direction to help figure what's going on here.. I've included the stack trace below:
ntoskrnl.exe!KeWaitForMultipleObjects+0xc0a
ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel+0x732
ntoskrnl.exe!KeWaitForMutexObject+0x19f
ntoskrnl.exe!NtWaitForSingleObject+0xde
ntoskrnl.exe!KeSynchronizeExecution+0x3a23
wow64cpu.dll!TurboDispatchJumpAddressEnd+0x6c0
wow64cpu.dll!TurboDispatchJumpAddressEnd+0x4a8
wow64.dll!Wow64SystemServiceEx+0x1ce
wow64.dll!Wow64LdrpInitialize+0x429
ntdll.dll!RtlIsDosDeviceName_U+0x24c87
ntdll.dll!LdrInitializeThunk+0xe
ntdll.dll!ZwWaitForSingleObject+0x15
ntdll.dll!RtlIntegerToUnicodeString+0x20b
MSDART.DLL!?ConvertExclusiveToShared#CReaderWriterLock3AR##QAEXXZ+0xb8
sqloledb.dll!DllUnregisterServer+0xa29b
sqloledb.dll!DllUnregisterServer+0xa05b
sqloledb.dll!DllUnregisterServer+0x9f70
sqloledb.dll+0x16e92
MyService.exe+0xea26a
This code had been working just fine for many years. This is a 32 bit C++ app, built with MS Visual Studio 2010. We started having issues after 2 changes happened and not sure if it's related or not, one the 32 bit built app is now running on a 64 bit Windows environment for the first time.. and two, the sql database is no longer local on the server, but is across the network.
This is a high volume server running hundreds or even thousands of transactions per minute, and every few days or longer, it's quite random, the code will just hang in the exact same spot, with the exact same stack trace as above..
Really would appreciate any suggestions as to how to figure out what's going on with sqloledb??
First question to start is why does the stack trace show that sqloledb is calling DllUnregisterServer?
From the stack trace it appears sql ole db is waiting for something with the WaitForMultipleObjects as the last call, but how can I figure out what it's waiting for?
Thank you.

QT Sqlite Unable to fetch row. Database locked

I am working on a QT C++ application which has a sqlite database. The tables are displayed using QTableView and QSqlTableModel. There are tables with around 10K records.
My issue is that when I try to update any record into a table with 10K records, I get the error as "Database is Locked, Unable to fetch row". This doesnt happen when the row count is less(say 20). The journal file is created in the applications folder. Seems some process is holding a lock onto database. Can't figure out the actual cause.
Can anyone suggest some solution?
Thanks,
Priyanka
In Qt, you send a PRAGMA to your database like this:
dbObj = QSqlDatabase::addDatabase(...);
dbObj.setDatabaseName(...);
dbObj.open();
dbObj.exec("PRAGMA locking_mode = EXCLUSIVE");
However, I don't think that is what you want. From the Qt documentation:
The driver is locked for updates while a select is executed. This may cause problems when using QSqlTableModel because Qt's item views fetch data as needed (with SqlQuery::fetchMore() in the case of QSqlTableModel).
Take a look at QSqlQuery::isActive which says:
Returns true if the query is active. An active QSqlQuery is one that has been exec()'d successfully but not yet finished with. When you are finished with an active query, you can make make the query inactive by calling finish() or clear(), or you can delete the QSqlQuery instance.
The bottom line is that you have a blocking query originating from somewhere that you either need to properly make "inactive" or that you'll need to arbitrate with.
Check to see if you have the sqlite database open in another window. I had the same issue but then noticed I had unsaved changes in another open window on the database. All worked perfectly once that instance was closed.

Failed to resume in time Crashlog

I am trying to figure out a "Failed to resume in time" problem. In one of our testers devices (which is an iPhone 4S with the latest OS) it happens very frequently, whereas in my own device it doesn't seem to happen at all.
Anyway, I got a few crashlogs. I am unable to trace the root of the cause though. I understand that the issue might be
1.When a process is holding up the main thread for too long.
2.When there is a memory issue.
I don't think the memory is much of an issue since it seems to happen when the user leaves the main menu and comes back. Nothing much is happening in the main menu so it probably is a task that runs too long.
Here is an excerpt from the crash log:
Can somebody help me or guide me on who I can trace the cause of the issue? Is there anyway to turn off the watchdog timer(probably not huh?) Also, what does highlighted thread refer to?
I have already checked my applicationDidBecomeActive & applicationWillEnterForeground to make sure there is nothing going on there.
To my knowledge there are no synchronous calls being made at this point. Does Reachability use synchronous calls to check for internet? How can I check for that?
I am not making any large data transfers upon resume.
I notice that GameCenter automatically logs in or check for log in upon resuming your app. Is there anyway to prevent this? Could this possibly cause a time out issue?
I tried doing a time profile, but I am not able to understand how to use it to analyze. If you can provide a good resource for that, that would be amazing.
Thanks!!!
You're currently in "trying to find the issue mode". You should switch to "try to find out how much of an issue this really is" mode.
So go find another 4S (actually as many as you can) to rule out that it's a device-specific issue. If it happens on all 4S it should be easier to pinpoint. If not, have someone else look over it, discuss possible causes. The peer programming approach often helps when you're stuck in a dead-end situation.
If the issue is only on that one device, you might want to check if it's broken (or "jailbroken") or might simply need a hard reboot (hold power and home for 10+ seconds).
If it only happens on some devices but not all, try to find what they have in common. This could be language/locale, or dictation, practically any kind of setting the user might have changed. If necessary, write a logger that logs as many settings as possible to your (web) server so you can compare settings one-by-one and quickly discard those that aren't in synch.
If only very few devices are affected, you could also ignore the issue and hope that additional crash logs from users will reveal the key to the issue.
Finally, there's always the option to disable suspend on terminate and instead terminate the app when the home button is pressed (as it was pre iOS 4). Unless of course the app has to run in background.