How to optimally and reliably go about sequentially applying updates with long running transactions?
Saturday, 14 January 2017 · 3 messages
MS
Mustard Seed14 Jan 2017 01:52 #
I'm new to BaseX and XQuery, so I apologize if there's some glaring thing I've missed.
What I have are three updating functions that I'm wanting to have executed sequentially, successfully, to BaseX.
When I simply place them in my RestXQ function, delimited by commas, they all execute, but since at times certain ones take longer than others, and since their results can overwrite/negate the results of each other, I can't manage to get them to consistently execute in the same order.
It seems to me that since it seemingly is running in parallel that whatever happens to end last determines what my final state is.
I imagine there's got to be some blatantly obvious way to do this, but I'm just not finding it, I went through the BaseX manual a second time and have searched every possible combination of things I can think of to try and figure out a way around this.
One function does a mass delete of all dbs with a given prefix, another repopulates from a sql query, and a third updates the repopulated dbs based on yet another sql query. That's the order I want it to execute in, I'm just about at my wits end trying to figure out how to do this. I was even getting into trying to pull off a hackish attempt at making jobs which I'd schedule based on a rough guess of the longest expected execution times for the functions. But even that wasn't working.
Any help will be greatly appreciated as insuring the order of execution is rather vital for the overall project I'm trying to do, so I need to not only find a solution for the present use case, but I need to understand how to insure such for any future composite functions.
Thanks,
--Nicolai
CG
Christian Grün14 Jan 2017 10:40 #
Hi Nicolai,
Welcome to the list.
The semantics of XQuery Update ensures that updates will be executed after at the end of query evaluation. This also means that your udates will always be executed at the same order [1].
In many cases, it will be possibly to rewrite sequential update operations to single ones. If that’s not possible – and in your case it may be tricky – you will have to define them in multiple RESTXQ functions and call them successively (see e.g. [2]).
Feel free to provide us with a minimized example, and I can give you some more hints.
Cheers,
Christian
[1] http://docs.basex.org/wiki/XQuery_Update#Concepts
[2] http://docs.basex.org/wiki/RESTXQ#Response
Quoted text · Mustard Seed · 38 lines
On Sat, Jan 14, 2017 at 12:52 AM, Mustard Seed <supercriticalfluid at gmail.com> wrote: > I'm new to BaseX and XQuery, so I apologize if there's some glaring thing > I've missed. > > What I have are three updating functions that I'm wanting to have executed > sequentially, successfully, to BaseX. > > When I simply place them in my RestXQ function, delimited by commas, they > all execute, but since at times certain ones take longer than others, and > since their results can overwrite/negate the results of each other, I can't > manage to get them to consistently execute in the same order. > > It seems to me that since it seemingly is running in parallel that whatever > happens to end last determines what my final state is. > > I imagine there's got to be some blatantly obvious way to do this, but I'm > just not finding it, I went through the BaseX manual a second time and have > searched every possible combination of things I can think of to try and > figure out a way around this. > > > One function does a mass delete of all dbs with a given prefix, another > repopulates from a sql query, and a third updates the repopulated dbs based > on yet another sql query. That's the order I want it to execute in, I'm just > about at my wits end trying to figure out how to do this. I was even getting > into trying to pull off a hackish attempt at making jobs which I'd schedule > based on a rough guess of the longest expected execution times for the > functions. But even that wasn't working. > > Any help will be greatly appreciated as insuring the order of execution is > rather vital for the overall project I'm trying to do, so I need to not only > find a solution for the present use case, but I need to understand how to > insure such for any future composite functions. > > Thanks, > > --Nicolai
CG
Christian Grün14 Jan 2017 10:50 #
PS: I have added a little example to our documentation that
demonstrates how RESTXQ redirection works;
http://docs.basex.org/wiki/Web_Module#web:redirect
Quoted text · Christian Grün · 63 lines
On Sat, Jan 14, 2017 at 10:40 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Nicolai, > > Welcome to the list. > > The semantics of XQuery Update ensures that updates will be executed > after at the end of query evaluation. This also means that your udates > will always be executed at the same order [1]. > > In many cases, it will be possibly to rewrite sequential update > operations to single ones. If that’s not possible – and in your case > it may be tricky – you will have to define them in multiple RESTXQ > functions and call them successively (see e.g. [2]). > > Feel free to provide us with a minimized example, and I can give you > some more hints. > > Cheers, > Christian > > [1] http://docs.basex.org/wiki/XQuery_Update#Concepts > [2] http://docs.basex.org/wiki/RESTXQ#Response > > > On Sat, Jan 14, 2017 at 12:52 AM, Mustard Seed > <supercriticalfluid at gmail.com> wrote: >> I'm new to BaseX and XQuery, so I apologize if there's some glaring thing >> I've missed. >> >> What I have are three updating functions that I'm wanting to have executed >> sequentially, successfully, to BaseX. >> >> When I simply place them in my RestXQ function, delimited by commas, they >> all execute, but since at times certain ones take longer than others, and >> since their results can overwrite/negate the results of each other, I can't >> manage to get them to consistently execute in the same order. >> >> It seems to me that since it seemingly is running in parallel that whatever >> happens to end last determines what my final state is. >> >> I imagine there's got to be some blatantly obvious way to do this, but I'm >> just not finding it, I went through the BaseX manual a second time and have >> searched every possible combination of things I can think of to try and >> figure out a way around this. >> >> >> One function does a mass delete of all dbs with a given prefix, another >> repopulates from a sql query, and a third updates the repopulated dbs based >> on yet another sql query. That's the order I want it to execute in, I'm just >> about at my wits end trying to figure out how to do this. I was even getting >> into trying to pull off a hackish attempt at making jobs which I'd schedule >> based on a rough guess of the longest expected execution times for the >> functions. But even that wasn't working. >> >> Any help will be greatly appreciated as insuring the order of execution is >> rather vital for the overall project I'm trying to do, so I need to not only >> find a solution for the present use case, but I need to understand how to >> insure such for any future composite functions. >> >> Thanks, >> >> --Nicolai
Written for BaseX 8.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery