You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bloodhound.apache.org by Peter Koželj <pe...@digiverse.si> on 2012/10/24 14:29:44 UTC

Datamodel and data consistency

Jure and I have been looking at the datamodel to see what would it take to
implement some of the enhancements that we have in mind.
Here are a couple of observations that pop up:

1. Parent/child relationships are not model by permanent ids but by names
(like version, milestone, product... name) that can be changed by user
through admin interface. A bit unusual but simple and eliminates the need
for joins when no additional data from the other entity is needed.

On the other side, renames of versions, milestones, products... (which are
indeed rare) require update of related tickets.
I imagine that renaming a product which has tens of thousands of tickets
could be a bit problematic. Much more worrying is that at least some of
these renames update tickets individually instead of as a single
SQL statement. At least this should be fixed.

So far this is more or less an implementation issue but it was brought to
my attention that it will escalate into software design issue if we wonted
to run BH in distributed environments (cloud).

2. There is no referential integrity imposed on the db level. But what is
even worse is that there is no data integrity check on application level
either.
     It seems that data integrity is left to the UI and the UI can not do
it even in theory. The following works for example:
      1. Open the new ticket page or popup
      2. Open admin in separate browser window and rename version (imagine
admin renaming staff while you are adding a new ticket)
      3. Switch back to window containing new ticket, it will offer old
version (which does not exists any more in database)
      4. You can now save this new ticket and it will refer to nonexistent
version

     There are other scenarios that can lead to this kind of corrupt data.


Peter

Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 11/2/12, Gary Martin <ga...@wandisco.com> wrote:
> On 2 November 2012 06:42, Olemis Lang <ol...@gmail.com> wrote:
>> On 11/1/12, Gary Martin <ga...@wandisco.com> wrote:
>>
[...]
>> > I think I
>> > worked out why we ended up with products using the full name. It is to
>> > do with the way that Trac's main ticket fields use the name field to
>> > specify the resources from other tables.

Now I recall

[...]
>> >
>> > I have ignored the issue of how information is displayed
>>
>> yes , that's what it seems .
>>
>> > so this is not
>> > really enough for to adapting other resources to use immutable keys.
>> > Any
>> > thoughts on these changes?
>> >
>>
>> so far looking good , but key + label in select controls is really
>> nice to have .
>>
>
> I was also thinking this but I think those patches will probably be a good
> enough starting point so I will commit those soon.
>

yes , of course ;)

> When I was looking at that possibility I was considering adding a
> dictionary alongside the options adjusted above in trac/trac/ticket/api.py
> to provide a mapping to what the label should be.

are you talking of field.options mapping present in select fields

> It would seem that we
> would have to override the way that such fields are pre-rendered.

afaics in order to add value + label in combobox for ticket select
field it's needed to . Target markup is rendered in Genshi template
rather than request handler (i.e. python code) which is the case for
field.rendered .

> I suppose
> that we should do that anyway as the ${field.rendered} values in the
> bh_ticket_box.html template result in links to the custom query instead of
> the dashboard style view for example.
>

IMO we could get such things done by using request filters , e.g.
using __modify_* methods in theme plugin , or maybe in a component
inside multi-product plugin .

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Re: Datamodel and data consistency

Posted by Gary Martin <ga...@wandisco.com>.
On 2 November 2012 06:42, Olemis Lang <ol...@gmail.com> wrote:

> On 11/1/12, Gary Martin <ga...@wandisco.com> wrote:
> > Hi,
> >
>
> :)
>
> > I'm afraid that I couldn't bring myself to wait for next week.
>
> heh !
> :)
>
> > I think I
> > worked out why we ended up with products using the full name. It is to
> > do with the way that Trac's main ticket fields use the name field to
> > specify the resources from other tables. We could of course change the
> > schema to respect this convention but, as we might consider other
> > changes to immutable fields, we could introduce a change like this to
> > core Trac:
> >
> [...]
> >
> > I have ignored the issue of how information is displayed
>
> yes , that's what it seems .
>
> > so this is not
> > really enough for to adapting other resources to use immutable keys. Any
> > thoughts on these changes?
> >
>
> so far looking good , but key + label in select controls is really
> nice to have .
>

I was also thinking this but I think those patches will probably be a good
enough starting point so I will commit those soon.

When I was looking at that possibility I was considering adding a
dictionary alongside the options adjusted above in trac/trac/ticket/api.py
to provide a mapping to what the label should be. It would seem that we
would have to override the way that such fields are pre-rendered. I suppose
that we should do that anyway as the ${field.rendered} values in the
bh_ticket_box.html template result in links to the custom query instead of
the dashboard style view for example.

Cheers,
    Gary

Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 11/1/12, Gary Martin <ga...@wandisco.com> wrote:
> Hi,
>

:)

> I'm afraid that I couldn't bring myself to wait for next week.

heh !
:)

> I think I
> worked out why we ended up with products using the full name. It is to
> do with the way that Trac's main ticket fields use the name field to
> specify the resources from other tables. We could of course change the
> schema to respect this convention but, as we might consider other
> changes to immutable fields, we could introduce a change like this to
> core Trac:
>
[...]
>
> I have ignored the issue of how information is displayed

yes , that's what it seems .

> so this is not
> really enough for to adapting other resources to use immutable keys. Any
> thoughts on these changes?
>

so far looking good , but key + label in select controls is really
nice to have .

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Re: Datamodel and data consistency

Posted by Gary Martin <ga...@wandisco.com>.
Hi,

I'm afraid that I couldn't bring myself to wait for next week. I think I 
worked out why we ended up with products using the full name. It is to 
do with the way that Trac's main ticket fields use the name field to 
specify the resources from other tables. We could of course change the 
schema to respect this convention but, as we might consider other 
changes to immutable fields, we could introduce a change like this to 
core Trac:

    Index: trac/trac/ticket/api.py
    ===================================================================
    --- trac/trac/ticket/api.py    (revision 1404839)
    +++ trac/trac/ticket/api.py    (working copy)
    @@ -165,6 +165,7 @@
              (rank, field)
              where field is a dictionary that defines:
                  * name: the field name
    +            * pk: the primary key of the field table
                  * label: the label to display, preferably wrapped with
    N_()
                  * cls: the model describing the field
              the following keys can also usefully be defined:
    @@ -344,7 +345,9 @@
              for rank, field in selects:
                  cls = field['cls']
                  name = field['name']
    -            options = [val.name for val in cls.select(self.env, db=db)]
    +            pk_field = field.get('pk', 'name')
    +            options = [getattr(val, pk_field)
    +                                for val in cls.select(self.env, db=db)]
                  if not options:
                      # Fields without possible values are treated as if
    they didn't
                      # exist


I believe that the above is an area that we are already patching to 
allow another way of playing with ticket fields. Anyway, with the above 
we can subsequently add the appropriate extra part of the specification 
and we start using a different key:

    Index: bloodhound_multiproduct/multiproduct/api.py
    ===================================================================
    --- bloodhound_multiproduct/multiproduct/api.py (revision 1404839)
    +++ bloodhound_multiproduct/multiproduct/api.py (working copy)
    @@ -122,7 +122,7 @@
          def get_select_fields(self):
              """Product select fields"""
              return [(35, {'name': 'product', 'label': N_('Product'),
    -                      'cls': Product, 'optional': True})]
    +                      'cls': Product, 'pk': 'prefix','optional':
    True})]

          def get_radio_fields(self):
              """Product radio fields"""


and any update of tickets reduces to a problem of informing that the 
event has happened which, until we consider this general problem in 
greater depth can simply be the following change:

    Index: bloodhound_multiproduct/multiproduct/model.py
    ===================================================================
    --- bloodhound_multiproduct/multiproduct/model.py (revision 1404839)
    +++ bloodhound_multiproduct/multiproduct/model.py (working copy)
    @@ -273,9 +273,8 @@
              now = datetime.now(utc)
              comment = 'Product %s renamed to %s' % (old_name, new_name)
              if old_name != new_name:
    -            for t in Product.get_tickets(self._env, old_name):
    +            for t in Product.get_tickets(self._env,
    self._data['prefix']):
                      ticket = Ticket(self._env, t['id'], db)
    -                ticket['product'] = new_name
                      ticket.save_changes(author, comment, now)

          @classmethod


I have ignored the issue of how information is displayed so this is not 
really enough for to adapting other resources to use immutable keys. Any 
thoughts on these changes?

Cheers,
     Gary


On 30/10/12 05:52, Peter Koz(elj wrote:
> Ok, I think we agree on most points. I do no see going away from Trac 
> in short term compelling either. It is just something to think about. 
> For products we have a couple of enhancements in mind; I would defer 
> the discussion until then (next week hopefully). Peter 


Re: Datamodel and data consistency

Posted by Peter Koželj <pe...@digiverse.si>.
On Mon, Oct 29, 2012 at 7:03 PM, Olemis Lang <ol...@gmail.com> wrote:

> On 10/29/12, Gary Martin <ga...@wandisco.com> wrote:
> >
> [...]
> > I don't want to be moving away from Trac [...]
> >
>
> +1 ... though I'd really like to see some gradual transition onto an
> ORM in the middle handling DB access e.g. like SqlAlchemyIntegration
> [1]_ .
>
> > It would certainly be difficult for plugin authors to support multiple
> > plugin models.
> >
> [...]
> >
> > To make that
> > work we would probably need to make sure that changes are generally
> > transparent and always easy to convert [...]
> >
>
> +1
>
> > Going back to the problem with multiproduct, I'm happy to see us
> > swapping to using the immutable product prefix. I am not yet convinced
> > of the argument of providing an extra field for the convenience of
> > allowing us to easily make the prefix mutable.
>
> The prefix must not be mutable if it will be used to identify product
> resources . Notice that in Trac there are other relations outside DB
> schema , the most notorious being TracLinks .
>
> > Withholding the ability
> > to change the prefix will be simplifying for the users of the system so
> > that they do not have to get used to referring to tickets through a new
> > prefix on the whim of another user. While we could provide the ability
> > for the old prefix to continue to be usable for identifying the
> > appropriate resource under the new prefix, the potential confusion in
> > discussions of tickets just seems unwarranted. The workaround exists of
> > creating a new product and moving the tickets into it.
> >
>
> +1 . Changes to product prefix should be an admin task carried out
> using external scripts , trac-admin commands or alike ...
>
> > As for the question of notifications, I agree that we don't want
> > multiple emails associated with a a change of product but I think it
> > would be nice for resources that were associated at the time of the
> > change to be able to report that the event has happened. On the other
> > hand, the activity feed should really only show one event at any given
> > scope.
>
> At present batch modifications contribute a single event to the timeline .
>
> > I am not convinced that that the bulk modify apparatus is the
> > correct approach for this in the long term.
> >
>
> It looks handy to reuse existing batch modifications .
>
> .. [1] Trac SQLAlchemy Bridge
>         (http://trac-hacks.org/wiki/TracSqlAlchemyBridgeIntegration)
>
> --
> Regards,
>
> Olemis.
>
> Blog ES: http://simelo-es.blogspot.com/
> Blog EN: http://simelo-en.blogspot.com/
>
> Featured article:
>

Ok, I think we agree on most points. I do no see going away from Trac in
short term compelling either. It is just something to think about.

For products we have a couple of enhancements in mind; I would defer the
discussion until then (next week hopefully).

Peter

Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 10/29/12, Gary Martin <ga...@wandisco.com> wrote:
>
[...]
> I don't want to be moving away from Trac [...]
>

+1 ... though I'd really like to see some gradual transition onto an
ORM in the middle handling DB access e.g. like SqlAlchemyIntegration
[1]_ .

> It would certainly be difficult for plugin authors to support multiple
> plugin models.
>
[...]
>
> To make that
> work we would probably need to make sure that changes are generally
> transparent and always easy to convert [...]
>

+1

> Going back to the problem with multiproduct, I'm happy to see us
> swapping to using the immutable product prefix. I am not yet convinced
> of the argument of providing an extra field for the convenience of
> allowing us to easily make the prefix mutable.

The prefix must not be mutable if it will be used to identify product
resources . Notice that in Trac there are other relations outside DB
schema , the most notorious being TracLinks .

> Withholding the ability
> to change the prefix will be simplifying for the users of the system so
> that they do not have to get used to referring to tickets through a new
> prefix on the whim of another user. While we could provide the ability
> for the old prefix to continue to be usable for identifying the
> appropriate resource under the new prefix, the potential confusion in
> discussions of tickets just seems unwarranted. The workaround exists of
> creating a new product and moving the tickets into it.
>

+1 . Changes to product prefix should be an admin task carried out
using external scripts , trac-admin commands or alike ...

> As for the question of notifications, I agree that we don't want
> multiple emails associated with a a change of product but I think it
> would be nice for resources that were associated at the time of the
> change to be able to report that the event has happened. On the other
> hand, the activity feed should really only show one event at any given
> scope.

At present batch modifications contribute a single event to the timeline .

> I am not convinced that that the bulk modify apparatus is the
> correct approach for this in the long term.
>

It looks handy to reuse existing batch modifications .

.. [1] Trac SQLAlchemy Bridge
        (http://trac-hacks.org/wiki/TracSqlAlchemyBridgeIntegration)

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Re: Datamodel and data consistency

Posted by Gary Martin <ga...@wandisco.com>.
On 29/10/12 07:57, Peter Koželj wrote:
> On Sat, Oct 27, 2012 at 11:11 AM, Joe Dreimann <
> joachim.dreimann@wandisco.com> wrote:
>
>> On 27 Oct 2012, at 04:29, Peter Koželj <pe...@digiverse.si> wrote:
>>> [...] as a user I surely don't
>>> need separate email for each affected ticket, just the one saying that
>>> product or milestone or whatever has changed would be enough.
>>>
>>> Peter
>> Fully agree.
>>
>> - Joe
>
> Ok, if I try to recap all this and try to think about what it all means:
>
> We agree that data model as is needs fixing (it is not enterprise or
> distributed environments friendly). Some of the fixes are local (like
> multiproduct plugin) for other it seems that we should just do them through
> BH and offer the solution to Trac. But what are the implications?
>
> 1. We would deviate from standard Trac quite a bit with a risk that our
> changes are accepted with a big delays or even rejected. Merging in new
> Trac versions could become a nightmare. Would we be willing to stay on Trac
> 1.0 for ever? And we would have to go from "...on the shoulders of Trac..."
> to "... not compatible with Trac...".
>
> 2. With the lack of data abstraction or data access constraints on a plugin
> level, plugins depend on this same database model. We will lose
> compatibility with most of the plugins that relay on the Trac database
> schema. And if we would insist on using some of the existing plugins for BH
> functionality we would be forced to fork them (see next point).
>
> 3. Adding data consistency on database level will break current plugin
> model. Data imports and schema upgrades become nontrivial and would require
> special inter plugin protocol to synchronise all that. Asking plugin
> authors to support two different data models and two different plugin
> models seems a bit much and would probably mean two different plugins (trac
> and BH) for the same functionality. So do we want entreprise DBA support or
> plugin authors support?
>
> Peter
>

I don't want to be moving away from Trac as I still think that both 
communities will be able to benefit from each other. We can probably 
expect the schema and APIs for Trac to evolve over time and so Trac 
presumably has to manage the same risk of breaking compatibility and 
pulling the trac-hack community with them.

It would certainly be difficult for plugin authors to support multiple 
plugin models. It is not unusual at this point to see plugins supporting 
older versions of Trac so for those it might be a question of how much 
can it hurt to support one more but, with no firm guarantees of our 
system being fixed, the effort to potentially support multiple versions 
of Bloodhound as well would probably put that in doubt too. To make that 
work we would probably need to make sure that changes are generally 
transparent and always easy to convert as well as supplying a lot of 
support for the process.

Going back to the problem with multiproduct, I'm happy to see us 
swapping to using the immutable product prefix. I am not yet convinced 
of the argument of providing an extra field for the convenience of 
allowing us to easily make the prefix mutable. Withholding the ability 
to change the prefix will be simplifying for the users of the system so 
that they do not have to get used to referring to tickets through a new 
prefix on the whim of another user. While we could provide the ability 
for the old prefix to continue to be usable for identifying the 
appropriate resource under the new prefix, the potential confusion in 
discussions of tickets just seems unwarranted. The workaround exists of 
creating a new product and moving the tickets into it.

As for the question of notifications, I agree that we don't want 
multiple emails associated with a a change of product but I think it 
would be nice for resources that were associated at the time of the 
change to be able to report that the event has happened. On the other 
hand, the activity feed should really only show one event at any given 
scope. I am not convinced that that the bulk modify apparatus is the 
correct approach for this in the long term.

Cheers,
     Gary

Re: Datamodel and data consistency

Posted by Peter Koželj <pe...@digiverse.si>.
On Sat, Oct 27, 2012 at 11:11 AM, Joe Dreimann <
joachim.dreimann@wandisco.com> wrote:

> On 27 Oct 2012, at 04:29, Peter Koželj <pe...@digiverse.si> wrote:
> > [...] as a user I surely don't
> > need separate email for each affected ticket, just the one saying that
> > product or milestone or whatever has changed would be enough.
> >
> > Peter
>
> Fully agree.
>
> - Joe


Ok, if I try to recap all this and try to think about what it all means:

We agree that data model as is needs fixing (it is not enterprise or
distributed environments friendly). Some of the fixes are local (like
multiproduct plugin) for other it seems that we should just do them through
BH and offer the solution to Trac. But what are the implications?

1. We would deviate from standard Trac quite a bit with a risk that our
changes are accepted with a big delays or even rejected. Merging in new
Trac versions could become a nightmare. Would we be willing to stay on Trac
1.0 for ever? And we would have to go from "...on the shoulders of Trac..."
to "... not compatible with Trac...".

2. With the lack of data abstraction or data access constraints on a plugin
level, plugins depend on this same database model. We will lose
compatibility with most of the plugins that relay on the Trac database
schema. And if we would insist on using some of the existing plugins for BH
functionality we would be forced to fork them (see next point).

3. Adding data consistency on database level will break current plugin
model. Data imports and schema upgrades become nontrivial and would require
special inter plugin protocol to synchronise all that. Asking plugin
authors to support two different data models and two different plugin
models seems a bit much and would probably mean two different plugins (trac
and BH) for the same functionality. So do we want entreprise DBA support or
plugin authors support?

Peter

Re: Datamodel and data consistency

Posted by Joe Dreimann <jo...@wandisco.com>.
On 27 Oct 2012, at 04:29, Peter Koželj <pe...@digiverse.si> wrote:
> [...] as a user I surely don't
> need separate email for each affected ticket, just the one saying that
> product or milestone or whatever has changed would be enough.
> 
> Peter

Fully agree.

- Joe

Re: Datamodel and data consistency

Posted by Peter Koželj <pe...@digiverse.si>.
On Fri, Oct 26, 2012 at 9:36 PM, Olemis Lang <ol...@gmail.com> wrote:

> On 10/26/12, Ryan Ollos <ry...@wandisco.com> wrote:
> > On Fri, Oct 26, 2012 at 1:41 AM, Jure Žitnik <ju...@digiverse.si> wrote:
> >
> >> I think we need a consistent 'notification strategy' which is basically
> >> deciding whether changes to structures related to tickets (products,
> >> milestones...) actually result in ticket notifications or not.
> >>
> >
> > This has been on my mind while working on some ticket, particular:
> > http://trac.edgewall.org/ticket/4582#comment:6
> > I've been thinking that I might open a dedicated ticket in the Trac core
> > after #4582 and #5658 are resolved to deal with the inconsistencies of
> when
> > notifications are sent.
> >
>
> What you are doing over there seems to be exactly like batch
> modifications . isn't it better to reuse batch modification code in
> query module and make the whole thing to look exactly like if logged
> in user had selected target tickets , set product=new_product and
> comment field set to something like «Renaming product XXX to YYY »?
>
> Besides there is a way to control whether notifications are sent or
> not . Take a look at the functions in TicketRPC class [1]_
>
> IMO _update_relations is not ok , and that's been my opinion since
> long time ago . The right way to go should be to use (immutable)
> product prefix rather than its name for all these sort of relations ,
> as stated in #110 . Modifying product prefix would be a more unlikely
> operation thus scripts for admin tasks would be ok to handle this .
> Nonetheless product names are more pretty and currently element value
> is always the same as element text.
>
> Q:
>
>   - Is there any trac hack to include id & value in select ticket fields ?
>
> .. [1] TicketRPC exported methods - from line 68 down to line 325
>         (
> http://trac-hacks.org/browser/xmlrpcplugin/trunk/tracrpc/ticket.py)
>
> --
> Regards,
>
> Olemis.
>
> Blog ES: http://simelo-es.blogspot.com/
> Blog EN: http://simelo-en.blogspot.com/
>
> Featured article:
>


Not sure why we would have to have ticket notification change events if I
rename a product from "My product" to "MyProduct". The same goes for
versions, milestones and the like. If the BH/trac needs them internally I
am sure there are ways around it, as a user I surely don't
need separate email for each affected ticket, just the one saying that
product or milestone or whatever has changed would be enough.

Peter

Re: Datamodel and data consistency

Posted by Ryan Ollos <ry...@wandisco.com>.
On Wed, Nov 7, 2012 at 9:20 AM, Ryan Ollos <ry...@wandisco.com> wrote:

> On Fri, Oct 26, 2012 at 12:36 PM, Olemis Lang <ol...@gmail.com> wrote:
>
>> [...]
>> What you are doing over there seems to be exactly like batch
>> modifications . isn't it better to reuse batch modification code in
>> query module and make the whole thing to look exactly like if logged
>> in user had selected target tickets , set product=new_product and
>> comment field set to something like «Renaming product XXX to YYY »?
>>
>
> I had studied the BatchModify class when starting that implementation and
> it looked like the BatchModify class would need some changes in order to
> directly utilize the it. The patch I've implemented does "make the whole
> thing to look exactly like if logged in user had selected target tickets",
> however I could see the advantage of code reuse from batch modify.
> Initially I dismissed this because I didn't want to dip into modifying the
> BatchModify class, but I will revisit this issue and post some comments to
> t.e.o ticket #4582 to see what the Trac developers have to say.
>

I've submitted a new patch which reuses code from the BatchModifyModule
class. I'll be interested to see what feedback the core developers have on
these changes. Please comments on that ticket if you have any suggestions
with regard to the implementation.

http://trac.edgewall.org/ticket/5658#comment:20

Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 11/7/12, Ryan Ollos <ry...@wandisco.com> wrote:
> On Fri, Oct 26, 2012 at 12:36 PM, Olemis Lang <ol...@gmail.com> wrote:
>
>> [...]
>> What you are doing over there seems to be exactly like batch
>> modifications . isn't it better to reuse batch modification code in
>> query module and make the whole thing to look exactly like if logged
>> in user had selected target tickets , set product=new_product and
>> comment field set to something like «Renaming product XXX to YYY »?
>>
>
> I had studied the BatchModify class when starting that implementation and
> it looked like the BatchModify class would need some changes in order to
> directly utilize the it. The patch I've implemented does "make the whole
> thing to look exactly like if logged in user had selected target tickets",
> however I could see the advantage of code reuse from batch modify.
> Initially I dismissed this because I didn't want to dip into modifying the
> BatchModify class, but I will revisit this issue and post some comments to
> t.e.o ticket #4582 to see what the Trac developers have to say.
>

Every few weeks I feel the same about something I have to do with Trac
and most of the time I can find the way to work around that . The
swiss army knife tool I've used most of the time to succeed is
bhdashboard.util.dummy_request . By using it we (mainly Gary and me
... but feel free to add name to the list ;) have been able to reuse
the methods offered by ReportsModule , QueryModule , TimelineModule
and so on in spite of building widgets rendering such content . One of
the situations I can mention we could not handle was the handling of
create ticket shortcut in theme plugin . Hence we incorporated methods
from XmlRpcPlugin . Needless to say that some modifications were
necessary . The most recent example is #195 . In there I combined
aforementioned technique with request filters so as to reuse
AttachmentModule._do_save method to handle file uploads .

Fact is that not doing things this way leads to a situation where
we'll have to maintain some code that does exactly the same Trac does
every day . As a consequence we might end up with situations like
TicketRPC.putAttachment which seems not to take into account
manipulators ... etc, etc, etc ...

That's the reason why , at least until Trac refactors their code to
make it more agnostic to web UI details , I strongly recommend to
reuse their methods rather than rewrite the same thing over and over .

... but you know ... practicality beats purity ... ;)

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Re: Datamodel and data consistency

Posted by Ryan Ollos <ry...@wandisco.com>.
On Fri, Oct 26, 2012 at 12:36 PM, Olemis Lang <ol...@gmail.com> wrote:

> [...]
> What you are doing over there seems to be exactly like batch
> modifications . isn't it better to reuse batch modification code in
> query module and make the whole thing to look exactly like if logged
> in user had selected target tickets , set product=new_product and
> comment field set to something like «Renaming product XXX to YYY »?
>

I had studied the BatchModify class when starting that implementation and
it looked like the BatchModify class would need some changes in order to
directly utilize the it. The patch I've implemented does "make the whole
thing to look exactly like if logged in user had selected target tickets",
however I could see the advantage of code reuse from batch modify.
Initially I dismissed this because I didn't want to dip into modifying the
BatchModify class, but I will revisit this issue and post some comments to
t.e.o ticket #4582 to see what the Trac developers have to say.

Re: Datamodel and data consistency

Posted by Peter Koželj <pe...@digiverse.si>.
On Fri, Oct 26, 2012 at 9:36 PM, Olemis Lang <ol...@gmail.com> wrote:

> On 10/26/12, Ryan Ollos <ry...@wandisco.com> wrote:
> > On Fri, Oct 26, 2012 at 1:41 AM, Jure Žitnik <ju...@digiverse.si> wrote:
> >
> >> I think we need a consistent 'notification strategy' which is basically
> >> deciding whether changes to structures related to tickets (products,
> >> milestones...) actually result in ticket notifications or not.
> >>
> >
> > This has been on my mind while working on some ticket, particular:
> > http://trac.edgewall.org/ticket/4582#comment:6
> > I've been thinking that I might open a dedicated ticket in the Trac core
> > after #4582 and #5658 are resolved to deal with the inconsistencies of
> when
> > notifications are sent.
> >
>
> What you are doing over there seems to be exactly like batch
> modifications . isn't it better to reuse batch modification code in
> query module and make the whole thing to look exactly like if logged
> in user had selected target tickets , set product=new_product and
> comment field set to something like «Renaming product XXX to YYY »?
>
> Besides there is a way to control whether notifications are sent or
> not . Take a look at the functions in TicketRPC class [1]_
>
> IMO _update_relations is not ok , and that's been my opinion since
> long time ago . The right way to go should be to use (immutable)
>

+1 for immutable, but I would go even further and used immutable generated
id so that we have an option open to have mutable product prefix in the
future (not necessarily a good idea but having the option is always better
than not having one)


> product prefix rather than its name for all these sort of relations ,
> as stated in #110 . Modifying product prefix would be a more unlikely
> operation thus scripts for admin tasks would be ok to handle this .
> Nonetheless product names are more pretty and currently element value
> is always the same as element text.
>
> Q:
>
>   - Is there any trac hack to include id & value in select ticket fields ?
>
> .. [1] TicketRPC exported methods - from line 68 down to line 325
>         (
> http://trac-hacks.org/browser/xmlrpcplugin/trunk/tracrpc/ticket.py)
>
> --
> Regards,
>
> Olemis.
>
> Blog ES: http://simelo-es.blogspot.com/
> Blog EN: http://simelo-en.blogspot.com/
>
> Featured article:
>

Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 10/26/12, Ryan Ollos <ry...@wandisco.com> wrote:
> On Fri, Oct 26, 2012 at 1:41 AM, Jure Žitnik <ju...@digiverse.si> wrote:
>
>> I think we need a consistent 'notification strategy' which is basically
>> deciding whether changes to structures related to tickets (products,
>> milestones...) actually result in ticket notifications or not.
>>
>
> This has been on my mind while working on some ticket, particular:
> http://trac.edgewall.org/ticket/4582#comment:6
> I've been thinking that I might open a dedicated ticket in the Trac core
> after #4582 and #5658 are resolved to deal with the inconsistencies of when
> notifications are sent.
>

What you are doing over there seems to be exactly like batch
modifications . isn't it better to reuse batch modification code in
query module and make the whole thing to look exactly like if logged
in user had selected target tickets , set product=new_product and
comment field set to something like «Renaming product XXX to YYY »?

Besides there is a way to control whether notifications are sent or
not . Take a look at the functions in TicketRPC class [1]_

IMO _update_relations is not ok , and that's been my opinion since
long time ago . The right way to go should be to use (immutable)
product prefix rather than its name for all these sort of relations ,
as stated in #110 . Modifying product prefix would be a more unlikely
operation thus scripts for admin tasks would be ok to handle this .
Nonetheless product names are more pretty and currently element value
is always the same as element text.

Q:

  - Is there any trac hack to include id & value in select ticket fields ?

.. [1] TicketRPC exported methods - from line 68 down to line 325
        (http://trac-hacks.org/browser/xmlrpcplugin/trunk/tracrpc/ticket.py)

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Re: Datamodel and data consistency

Posted by Ryan Ollos <ry...@wandisco.com>.
On Fri, Oct 26, 2012 at 1:41 AM, Jure Žitnik <ju...@digiverse.si> wrote:

> I think we need a consistent 'notification strategy' which is basically
> deciding whether changes to structures related to tickets (products,
> milestones...) actually result in ticket notifications or not.
>

This has been on my mind while working on some ticket, particular:
http://trac.edgewall.org/ticket/4582#comment:6
I've been thinking that I might open a dedicated ticket in the Trac core
after #4582 and #5658 are resolved to deal with the inconsistencies of when
notifications are sent.


> If we choose that the change of related structure actually triggers ticket
> change we should keep in mind that even if we optimize the actual structure
> update, we'd still have to do ticket change notifications for all related
> tickets (which would result in huge database queries to fetch all affected
> tickets anyway).
>

I need to look more closely at the implementation to say for certain that
we don't need to be concerned about this, but I think that BatchNotifyEmail
(1) exists to deal with this situation, as I've utilized in (2) by just
following standard patterns seen in the Trac core. The AnnouncerPlugin
doesn't yet support batch notifications as far as I know, but I haven't
tested it out with Trac 1.0 in which the BatchNotifyEmail class was added.

(1) http://trac.edgewall.org/browser/trunk/trac/ticket/notification.py#L444
(2) http://trac.edgewall.org/attachment/ticket/5658/t5658-r11413-1.patch

Re: Datamodel and data consistency

Posted by Jure Žitnik <ju...@digiverse.si>.
On 10/25/12 8:57 PM, Olemis Lang wrote:
> [...]
>>> When milestone, component and version are updated, the updates to the
>>> milestone/component/version table and tickets table occur in a single
>>> transaction (3), per my limited understanding. Priority and Severity are
>>> less fortunate, as the definitions of these fields are stored in
>>> trac.ini,
>>> and changes to the values will not result in any ticket updates.

Actually, resolution, priority and severity update corresponding ticket 
fields within a transaction 
(http://trac.edgewall.org/browser/trunk/trac/ticket/model.py?marks=793,808-812&rev=11359#L790) 
as they all derive from Abstract enum.

>>
>> That code for milestone update (reference 3) is ok (given the datamodel).
>> However in bloodhound_multiproduct/multiproduct/model.py
>> Product._update_relations() you can find this:
>>
>> for t in Product.get_tickets(self._env, old_name):
>>                  ticket = Ticket(self._env, t['id'], db)
>>                  ticket['product'] = new_name
>>                  ticket.save_changes(author, comment, now)
>>
>>
>> Not sure if it is single transaction or not,
> it does not seem so

It's a single transaction, it's established in the update() method 
before this code gets called.

>> If you have 10000 tickets in a product, that will be 10000 roundtrips to
>> the SQL server.
>>
> yes ... we are the ones who have to improve that code snippet and use
> transactions and/or something more efficient .
>

I agree that the update part needs to be improved, I would suggest we go 
with the same approach as it's used in trac core for component update, 
but I suspect that the current implementation was chosen to enable 
notifications for ticket product update (change notifications)... so, I 
guess the problem is a bit wider..

What we should keep in mind when discussing data model and data 
consistency is the dependencies that rely upon ticket changes and 
related structures, namely ticket change notifications (upon which many 
plugins depend, announcer plugin being one example). Looking at 
ITicketChangeListener extension point, currently updates (renames) to 
various related structures (component, milestone, version, product...) 
produce inconsistent results. Renaming a product for example would 
trigger ticket change listeners, most of the other changes (resolution, 
priority, severity...) wouldn't. Milestone change is special case as it 
even defines it's own extension point for milestone changes (not really 
sure why).

I think we need a consistent 'notification strategy' which is basically 
deciding whether changes to structures related to tickets (products, 
milestones...) actually result in ticket notifications or not. If we 
choose that the change of related structure actually triggers ticket 
change we should keep in mind that even if we optimize the actual 
structure update, we'd still have to do ticket change notifications for 
all related tickets (which would result in huge database queries to 
fetch all affected tickets anyway).

Cheers,
Jure


-- 
Jure Žitnik
email: jure@digiverse.si
skype: jzitnik
mobile: +386 41 378 597

Digiverse d.o.o.
Dolenjska cesta 318
1291 Škofljica
www.digiverse.si


Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 10/25/12, Peter Koželj <pe...@digiverse.si> wrote:
> On Thu, Oct 25, 2012 at 12:16 AM, Ryan Ollos
> <ry...@wandisco.com>wrote:
>
>> On Wed, Oct 24, 2012 at 5:29 AM, Peter Koželj <pe...@digiverse.si> wrote:
>>
[...]
>>
>> When milestone, component and version are updated, the updates to the
>> milestone/component/version table and tickets table occur in a single
>> transaction (3), per my limited understanding. Priority and Severity are
>> less fortunate, as the definitions of these fields are stored in
>> trac.ini,
>> and changes to the values will not result in any ticket updates.
>>
>> (1) http://trac.edgewall.org/ticket/10925
>> (2) http://trac.edgewall.org/ticket/5658
>> (3)
>>
>> http://trac.edgewall.org/browser/trunk/trac/ticket/model.py?marks=1061,1064-1069,1075-1076&rev=11359#L1051
>
>
> That code for milestone update (reference 3) is ok (given the datamodel).
> However in bloodhound_multiproduct/multiproduct/model.py
> Product._update_relations() you can find this:
>
> for t in Product.get_tickets(self._env, old_name):
>                 ticket = Ticket(self._env, t['id'], db)
>                 ticket['product'] = new_name
>                 ticket.save_changes(author, comment, now)
>
>
> Not sure if it is single transaction or not,

it does not seem so

> but it is N SQL updates for
> sure.
>
> If you have 10000 tickets in a product, that will be 10000 roundtrips to
> the SQL server.
>

yes ... we are the ones who have to improve that code snippet and use
transactions and/or something more efficient .

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Re: Datamodel and data consistency

Posted by Peter Koželj <pe...@digiverse.si>.
On Thu, Oct 25, 2012 at 12:16 AM, Ryan Ollos <ry...@wandisco.com>wrote:

> On Wed, Oct 24, 2012 at 5:29 AM, Peter Koželj <pe...@digiverse.si> wrote:
>
> > Jure and I have been looking at the datamodel to see what would it take
> to
> > implement some of the enhancements that we have in mind.
> > Here are a couple of observations that pop up:
> >
> > 1. Parent/child relationships are not model by permanent ids but by names
> > (like version, milestone, product... name) that can be changed by user
> > through admin interface. A bit unusual but simple and eliminates the need
> > for joins when no additional data from the other entity is needed.
> >
> > On the other side, renames of versions, milestones, products... (which
> are
> > indeed rare) require update of related tickets.
> > I imagine that renaming a product which has tens of thousands of tickets
> > could be a bit problematic. Much more worrying is that at least some of
> > these renames update tickets individually instead of as a single
> > SQL statement. At least this should be fixed.
> >
>
> Could you point out some code examples of these individual updates so I can
> better understand what you are referring to? I've been working on a patch
> to deal with the lack of milestone change history when tickets are
> re-targeted as a milestone is closed (1, 2). In the course of this, I'm
> starting to understand (barely), how these multiple statements can be
> executed within a single transaction. I think that is related to what you
> are referring to.
>
> When milestone, component and version are updated, the updates to the
> milestone/component/version table and tickets table occur in a single
> transaction (3), per my limited understanding. Priority and Severity are
> less fortunate, as the definitions of these fields are stored in trac.ini,
> and changes to the values will not result in any ticket updates.
>
> (1) http://trac.edgewall.org/ticket/10925
> (2) http://trac.edgewall.org/ticket/5658
> (3)
>
> http://trac.edgewall.org/browser/trunk/trac/ticket/model.py?marks=1061,1064-1069,1075-1076&rev=11359#L1051


That code for milestone update (reference 3) is ok (given the datamodel).
However in bloodhound_multiproduct/multiproduct/model.py
Product._update_relations() you can find this:

for t in Product.get_tickets(self._env, old_name):

                ticket = Ticket(self._env, t['id'], db)

                ticket['product'] = new_name

                ticket.save_changes(author, comment, now)


Not sure if it is single transaction or not, but it is N SQL updates for
sure.

If you have 10000 tickets in a product, that will be 10000 roundtrips to
the SQL server.


Peter

Re: Datamodel and data consistency

Posted by Ryan Ollos <ry...@wandisco.com>.
On Wed, Oct 24, 2012 at 5:29 AM, Peter Koželj <pe...@digiverse.si> wrote:

> Jure and I have been looking at the datamodel to see what would it take to
> implement some of the enhancements that we have in mind.
> Here are a couple of observations that pop up:
>
> 1. Parent/child relationships are not model by permanent ids but by names
> (like version, milestone, product... name) that can be changed by user
> through admin interface. A bit unusual but simple and eliminates the need
> for joins when no additional data from the other entity is needed.
>
> On the other side, renames of versions, milestones, products... (which are
> indeed rare) require update of related tickets.
> I imagine that renaming a product which has tens of thousands of tickets
> could be a bit problematic. Much more worrying is that at least some of
> these renames update tickets individually instead of as a single
> SQL statement. At least this should be fixed.
>

Could you point out some code examples of these individual updates so I can
better understand what you are referring to? I've been working on a patch
to deal with the lack of milestone change history when tickets are
re-targeted as a milestone is closed (1, 2). In the course of this, I'm
starting to understand (barely), how these multiple statements can be
executed within a single transaction. I think that is related to what you
are referring to.

When milestone, component and version are updated, the updates to the
milestone/component/version table and tickets table occur in a single
transaction (3), per my limited understanding. Priority and Severity are
less fortunate, as the definitions of these fields are stored in trac.ini,
and changes to the values will not result in any ticket updates.

(1) http://trac.edgewall.org/ticket/10925
(2) http://trac.edgewall.org/ticket/5658
(3)
http://trac.edgewall.org/browser/trunk/trac/ticket/model.py?marks=1061,1064-1069,1075-1076&rev=11359#L1051

Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 10/25/12, Branko Čibej <br...@wandisco.com> wrote:
> On 25.10.2012 09:02, Olemis Lang wrote:
>> On 10/24/12, Branko Čibej <br...@wandisco.com> wrote:
>>> On 25.10.2012 04:52, Olemis Lang wrote:
>>>> On 10/24/12, Peter Koželj <pe...@digiverse.si> wrote:
>> [...]
>>>> This is what Trac-dev should be working towards regarding relations of
>>>> any kind between resources .
>>>>
>>>> http://trac.edgewall.org/wiki/TracDev/Proposals/TracRelations
>>> That page was last updated 4 years ago. Are you seriously suggesting
>>> that referring this question to trac-dev@ will, after all this time,
>>> have any measurable effect?
>>>
>> yes , there are recent conversations where it was cited , especially
>> regarding post-Trac 1.0 schedule . Indeed multi-project proposal [1]_
>> is another example , last updated 3 y ago , and there's some recent
>> work on that direction [2]_ . It's worth to mention that target t-h.o
>> plugin seems to be intended to be incorporated into Trac at a given
>> time in the future . The spec is also the starting point (and
>> inspiration) for our own initial approach towards multi-product
>> support .
>
> I think it's a better approach to just implement these things the way
> they should be done, then propose patches to trac-dev. The other way
> around is going to take forever.
>

+1 ... that's why we have our own development branch towards this goal

> I won't describe the headache I got when I tried to reconcile the
> TracRelations proposal with relational data modelling principles, or
> abstraction layering principles.
>

well , it's more similar to other techs like non-relational DBs , BPMS
, ... indeed afaicr it is somehow based or some parts inspired on some
Java BPMS ... don't recall the details though . Such
decoupled/generic/abstract DB scenarios are quite common these days
... /me not saying they are always right , though

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Re: Datamodel and data consistency

Posted by Branko Čibej <br...@wandisco.com>.
On 25.10.2012 09:02, Olemis Lang wrote:
> On 10/24/12, Branko Čibej <br...@wandisco.com> wrote:
>> On 25.10.2012 04:52, Olemis Lang wrote:
>>> On 10/24/12, Peter Koželj <pe...@digiverse.si> wrote:
> [...]
>>> This is what Trac-dev should be working towards regarding relations of
>>> any kind between resources .
>>>
>>> http://trac.edgewall.org/wiki/TracDev/Proposals/TracRelations
>> That page was last updated 4 years ago. Are you seriously suggesting
>> that referring this question to trac-dev@ will, after all this time,
>> have any measurable effect?
>>
> yes , there are recent conversations where it was cited , especially
> regarding post-Trac 1.0 schedule . Indeed multi-project proposal [1]_
> is another example , last updated 3 y ago , and there's some recent
> work on that direction [2]_ . It's worth to mention that target t-h.o
> plugin seems to be intended to be incorporated into Trac at a given
> time in the future . The spec is also the starting point (and
> inspiration) for our own initial approach towards multi-product
> support .

I think it's a better approach to just implement these things the way
they should be done, then propose patches to trac-dev. The other way
around is going to take forever.

I won't describe the headache I got when I tried to reconcile the
TracRelations proposal with relational data modelling principles, or
abstraction layering principles.

-- Brane

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download


Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 10/24/12, Branko Čibej <br...@wandisco.com> wrote:
> On 25.10.2012 04:52, Olemis Lang wrote:
>> On 10/24/12, Peter Koželj <pe...@digiverse.si> wrote:
>>>
[...]
>> This is what Trac-dev should be working towards regarding relations of
>> any kind between resources .
>>
>> http://trac.edgewall.org/wiki/TracDev/Proposals/TracRelations
>
> That page was last updated 4 years ago. Are you seriously suggesting
> that referring this question to trac-dev@ will, after all this time,
> have any measurable effect?
>

yes , there are recent conversations where it was cited , especially
regarding post-Trac 1.0 schedule . Indeed multi-project proposal [1]_
is another example , last updated 3 y ago , and there's some recent
work on that direction [2]_ . It's worth to mention that target t-h.o
plugin seems to be intended to be incorporated into Trac at a given
time in the future . The spec is also the starting point (and
inspiration) for our own initial approach towards multi-product
support .

Child was born years ago but still having the same DNA
;)

> There comes a point when you'll have to face the fact that Trac hasn't
> exactly been a hotbed of innovation and new developments recently.
> Which, I understand, happens to be one of the reasons for the existence
> of Bloodhound in the first place.
>

I guess that's the reason in first place , but maybe add to the list
«Trac-dev not joining the ASF» ...

.. [1] Multiple Projects within a Single Trac Environment
        (http://trac.edgewall.org/wiki/TracMultipleProjects/SingleEnvironment)

.. [2] SimpleMultiProjectPlugin - Recent changes
        (http://trac-hacks.org/wiki/SimpleMultiProjectPlugin#RecentChanges)

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Re: Datamodel and data consistency

Posted by Branko Čibej <br...@wandisco.com>.
On 25.10.2012 04:52, Olemis Lang wrote:
> On 10/24/12, Peter Koželj <pe...@digiverse.si> wrote:
>> Jure and I have been looking at the datamodel to see what would it take to
>> implement some of the enhancements that we have in mind.
>> Here are a couple of observations that pop up:
>>
>> 1. Parent/child relationships are not model by permanent ids but by names
>> (like version, milestone, product... name) that can be changed by user
>> through admin interface. A bit unusual but simple and eliminates the need
>> for joins when no additional data from the other entity is needed.
>>
> This is what Trac-dev should be working towards regarding relations of
> any kind between resources .
>
> http://trac.edgewall.org/wiki/TracDev/Proposals/TracRelations

That page was last updated 4 years ago. Are you seriously suggesting
that referring this question to trac-dev@ will, after all this time,
have any measurable effect?

There comes a point when you'll have to face the fact that Trac hasn't
exactly been a hotbed of innovation and new developments recently.
Which, I understand, happens to be one of the reasons for the existence
of Bloodhound in the first place.

-- Brane

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download


Re: Datamodel and data consistency

Posted by Olemis Lang <ol...@gmail.com>.
On 10/24/12, Peter Koželj <pe...@digiverse.si> wrote:
> Jure and I have been looking at the datamodel to see what would it take to
> implement some of the enhancements that we have in mind.
> Here are a couple of observations that pop up:
>
> 1. Parent/child relationships are not model by permanent ids but by names
> (like version, milestone, product... name) that can be changed by user
> through admin interface. A bit unusual but simple and eliminates the need
> for joins when no additional data from the other entity is needed.
>

This is what Trac-dev should be working towards regarding relations of
any kind between resources .

http://trac.edgewall.org/wiki/TracDev/Proposals/TracRelations

> On the other side, renames of versions, milestones, products... (which are
> indeed rare) require update of related tickets.
> I imagine that renaming a product which has tens of thousands of tickets
> could be a bit problematic. Much more worrying is that at least some of
> these renames update tickets individually instead of as a single
> SQL statement. At least this should be fixed.
>

I'm not sure of whether I understood correctly , but transactions
might help to roll back unwanted modifications ...

> 2. There is no referential integrity imposed on the db level. But what is
> even worse is that there is no data integrity check on application level
> either.

Your experiment yields accurate conclusions . Maybe there will be some
answers if you forward your concerns to trac-dev .

[...]

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article: