flyway - Repeatable scripts not repeated - java

I have recently moved from an old database migration provider to flyway (4.1.2). In our setup we have - as usual - some incremental scripts and scripts that are repeatable. So far things have worked well and I was able to recreate most of the behavior we had before with some improvements thanks to flyway. However I am experiencing weird behavior with repeatable scripts.
Lets imagine the following scripts:
DELETE FROM CONFIGURATION;
INSERT INTO CONFIGURATION (KEY, VALUE) VALUES ('SAF_DELAY', '22');
it gets executed when created and does what it is supposed to. Also an entry in schema_version is created with the checksum. Now I change the 22to 23and run flyway:migrate again, the script is executed and creates a second entry in schema_version with the new checksum. A while later I realize that the 23 is actually bad and 22 was right from the beginning so I change it back.
Now flyway refuses to execute the script again telling me that everything is up to date even though the script has changed from its previous state. I am assuming it does so because it can still find the old entry in the schema_version.
Obviously that is undesired behavior for a repeatable script, the decision point should only be the last executed checksum and not any checksum that ever executed of the script. This is also what I assume the documentation means by "Instead they are (re-)applied every time their checksum changes." I was looking through the configuration section of the maven plugin but could not find anything that seemed like a solution.
Since this is kind of a deal breaker for me I would be happy if you could hint me to the right direction.

Related

Clear some stuff from Nailgun cache (usage: Jython)

This is a bit technical, and follows on from Using Nailgun in Eclipse for Java and Jython.
I have found out how to get Nailgun to work OK in on a Windows OS in Eclipse, using Jython. And using the unittest module.
What is baffling is that sometimes I make a change to a .py file, and sometimes (not always), an older version of this file continues to be run. This can even persist when I close down the Nailgun server, close its window, and start it up again: an old version of a file is being run, which no longer exists.
This feels very much like a cache problem. My understanding is that Jython does not generate .class files usually (although sometimes it does if you import a module??).
But perhaps this is indeed what Nailgun is doing. I have done some searching on my C: drive to see whether this cache location might be easy to locate: no luck.
Essentially I need the ability to tell Nailgun, between app runs, to delete a given .class file from whatever cache arrangement it maintains.
Incidentally, it doesn't matter whether the CLASSPATH elements in question are stipulated in the server's "SET CLASSPATH=..." or using the "ng-cp" option in the ng command line (i.e. in the client).
If all else fails I shall probably have to look into the NG source for inspiration. Gulp.

SVN commit behavior / failure criateria

So I'm making some changes/fixes to someone's subclipse mod and had a few questions.
First, I noticed that an svn commit fails when trying to commit a single file that is identical to the existing one in the repository. (And returns -1 for the revision #) Makes sense.
Does this happen if you commit multiple files, only some of which have no changes?
Is the best way around this to just do a diff (on every file?) before attempting to commit?
If anyone knows, that'd be great. Or if you can point me in the right direction? (My google-fu failed me)
If the file is identical, SVN will not commit it. If you provide a list of files, the ones that are identical will just be skipped. I assume you are working with the SVN API and not Subclipse GUI or command line client as you do not see a -1 in either of those.
If you are 100% sure the file is 'identical', then the quickest solution would be to do a 'revert' on the troublesome file (by right-clicking on the file then selecting 'Team' then 'Revert'). Subversion does 'atomic' commits, ( What is the value of atomic commits in Subversion? ) , which basically means if one commit fails in a batch commit, then they all fail.

Create Eclipse SVN "virtual branches"?

I program Java using Eclipse and SVN in my company and one of the commit rules it's that each commit have their own purpose, and it's always one.
Sometimes I can get some work done but can't publish it on the server until the end of the day (it will break the build) and then I have to do some other work (non related to the first) and commit it, but if I do that I'm commiting changes related to 2 tasks.
What I want here it's to have a way to say to Eclipse that I want to separate those changes and on both of the tasks I want to work with the trunk code. So, basically it's a branch, but that never existed, in order to let me make separate commits. I thought about having N eclipse workspaces working with the trunk code and use each onde for each change, but that seems overkilling.
Is it doable?
In Intellij you have changelists that you can commit separately. Maybe this question can help you further on your way: Changelists in subclipse
The only way I can think of doing it so that you can make two different sets of changes within a single file is to checkout a second working copy for the second tasks set of changes, and work on those independently. When either task is complete you can commit the changes made in that working copy, and update the other working copy before committing that once it builds.

Is there a way to disable calls to Runtime.checkRestricted on the GAE Java development server under Eclipse?

I'm one of those guys who step through their code a lot during development. Beginning with version 1.6.4 of the GAE Java development server, the server has been instrumented with calls to a function named Runtime.checkRestricted. This causes two inconveniences when I step through my code:
Whenever I step into a function, the debugger goes into the function Runtime.checkRestricted (for which there is no source code) at least once, often multiple times.
Whenever I step over a function call which has a large call tree underneath, it takes a very long time for the debugger to come back. (That's always a problem in the Eclipse Java debugger, but now it's really bad.)
For me, all this causes a serious drain on productivity. Is there any way to disable this instrumentation, or at least to prevent the debugger from stepping into it? I am using Eclipse with the GAE plugin.
Add a step filter to filter out all step breakpoints you are not interested in. The Eclipse documention provides a guide how to set up step filter.
In your specific case, you will want to add a package filter for com.google.appengine.tools.development.* , as this package and its subpackages contain GAE's Runtime class and RuntimeHelper class. Finally, don't forget to activate the option "Use Step Filters" (Shift + F5).

Database record reverting after manual change

Problem solved: Thanks guys, see my answer below.
I have a website running in Tomcat 5.5 hooked up to a MySQL5 database using Hibernate3.
One record simply refuses to keep any changes performed on it. If I change the record programmatically, the values revert back to what they were previously.
If I manually modify the record in the database, the values will revert (seemingly once the webapp accesses them).
I have tried stopping Tomcat and changing the values manually then starting Tomcat again. Checking the database, the values remain changed after Tomcat has started the webapp but will revert back again once I load the site.
I have also tried deleting the Tomcat work folder for the webapp and the .ser cache file.
I have also checked the code for the values that are being reverted to and cannot find them.
I have only noticed it on this one particular record.
Edit: I've just had a look at the SQL output from Hibernate using hibernate.show_sql=true. There is an update query logged for the table my row is in. Does anyone know how to resolve the ? for the columns to actual values?
You could temporarily enable the mysql query logging and see exactly what sql statement altered the value. Since you say it changes immediately after the server starts you should be able to figure out the statement pretty quickly.
http://dev.mysql.com/doc/refman/5.0/en/query-log.html
To answer your question:
Does anyone know how to resolve the ?
for the columns to actual values?
You can do this with p6spy. Instructions for how to set this up in a Spring app are available here.
However, I think there's a mistake in these instructions, the file they refer to as p6spy.log should actually be name p6spy.properties.
It's getting close to halloween, so you have to expect this sort of thing (plus it was just a full moon), but I'd keep looking for the culprit in the web application ... it HAS to be there. A couple values I'd immediately search for in the webapp source code:
The id of the record being changed.
The value that's being written into
the record.
Good luck ... these can be real bears to find!
This smells a little like a test-case firing on start up that modifies the row to what it expects it to be before testing.
Add a trigger BEFORE UPDATE, check row id, raise an SQL error if it matches your magic row.
Then check the generated stacktrace, walk the code and locate the piece that updates the row.
Thanks to everyone for the help. All of the suggestions came in handy for tracking it down.
I've managed to find out what was causing it. Bad database design, multiple data models and Hibernate makes for some nasty stuff. Another table had the value stored and that class was extending a base class with the same value.
Time to look at doing some normalisation.

Categories