SQL Server – How Can I Detect a Locked Table and Endless Query Problem?

I have a table that is regularly locked in a way that I don't fully understand. I can't do the following:

select * from thetable
select count(*) from thetable

There are approximately 2,000 records.

I can do the following:

select top 2000 * from thetable
select * from thetable where ID = etc.

Go backwards to find a new record that may have been problematic and increase the number in pieces until I can finally reproduce it:

select top 1500 * from thetable order by ID desc
select top 1550.... etc. and eventually it gets locked and never finishes the query.

The query never ends. I waited 10 minutes. The only solution is to restart the service.

The associated stored procedure that I thought was causing the problem that I ran manually (it interacts with this table) and the longest time it took was about 45 seconds. This special procedure goes through many phases and is included in a transaction with a try / catch / rollback / commit. No explicit lock is set for the procedure.

Any instruction or guidance to track down the basic problem is greatly appreciated.

Unity – infinite terrain for endless runner game

Thank you for your response to Game Development Stack Exchange!

  • Please be sure answer the question. Provide details and share your research!

But avoid

  • Ask for help, clarify, or respond to other answers.
  • Make statements based on opinions; Support them with references or personal experiences.

Use MathJax to format equations. MathJax reference.

For more information, see our tips on writing great answers.

C # – Android – Execute endless code in the foreground while using the app

I'm making an application that I want to have the ability to send report emails with a frequency. daily, weekly or monthly.

Now I want these emails to be sent only when the app is running and when the user is using them (in my app you use the phone as a kiosk, you open the app and let it run all the time, the screen will not closed).

I wrote this code in the main activity. If someone has enabled the frequent email feature, the activity tries to send the email (SendStatisticsToEmailBySchedule () will run forever and will use SendStatisticsToEmail () send an email from time to time):

public async void SendStatisticsToEmail(string subject, string address, int port, string from, string to, bool useSSL, bool saveDateSent = false, string username = "http://codereview.stackexchange.com/", string password = "http://codereview.stackexchange.com/", bool sendNowButtonUsed = false)
        {
            var fileName = System.IO.Path.Combine(
                GetString(Resource.String.Statistics_ExportAllExportPrefix,
                firstResult.ToString("MM-dd-yyyy"),
                DateTime.Today.ToString("MM-dd-yyyy")));

            var message = new MimeMessage();
            message.From.Add(new MailboxAddress(from));
            message.To.Add(new MailboxAddress(to));
            message.Subject = subject + "http://codereview.stackexchange.com/" + fileName;

            var statistics = new Statistics();
            var reportsForXML = statistics.ConvertRecordsForExport(MyData);
            MemoryStream stream = new MemoryStream();

            var builder = new BodyBuilder();
            var image = BitmapFactory.DecodeResource(Resources, Resource.Drawable.get_started);
            byte() imgbyte;
            using (var bitmap = image)
            {
                var streamByte = new MemoryStream();
                bitmap.Compress(Bitmap.CompressFormat.Png, 100, streamByte);
                bitmap.Recycle();
                imgbyte = streamByte.ToArray();
            }
            var imageAttach = builder.LinkedResources.Add(@"get_started.png", imgbyte);
            imageAttach.ContentId = MimeUtils.GenerateMessageId();
            builder.HtmlBody = string.Format(@"

{1}

{2}

{3}

", new object() { imageAttach.ContentId, GetString(Resource.String.EmailExportSettings_MessageBodyLine1), GetString(Resource.String.EmailExportSettings_MessageBodyLine2), GetString(Resource.String.EmailExportSettings_MessageBodyLine3) }); using (System.IO.StreamWriter writer = new System.IO.StreamWriter(stream)) { reportsForXML.WriteXml(writer, XmlWriteMode.WriteSchema, false); stream.Position = 0; builder.Attachments.Add(fileName, stream); } message.Body = builder.ToMessageBody(); try { using (var client = new SmtpClient()) { // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS) client.ServerCertificateValidationCallback = (s, c, h, e) => true; if (useSSL) await client.ConnectAsync(address, port, SecureSocketOptions.SslOnConnect); else await client.ConnectAsync(address, port, false); // Note: only needed if the SMTP server requires authentication if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) client.Authenticate(username, password); await client.SendAsync(message); await client.DisconnectAsync(true); if (saveDateSent) { Preferences.Set(Settings.ExportToEmailLastEmailSentKey, DateTime.Now); ScheduleNextEmailForSend(DateTime.Now, Preferences.Get(Settings.ExportToEmailEmailFrequencyPositionKey, Settings.ExportToEmailEmailFrequencyPositionDefault) ); } if (sendNowButtonUsed) Toast.MakeText(this, GetString(Resource.String.Statistics_EmailSendSuccess), ToastLength.Long).Show(); } } catch //(Exception exception) { if (sendNowButtonUsed) Toast.MakeText(this, GetString(Resource.String.Statistics_EmailSendFailure), ToastLength.Long).Show(); } } private void ScheduleNextEmailForSend(DateTime nextScheduledEmailDate, int frequency) { nextScheduledEmailDate = DateTime.Now; frequency = Preferences.Get(Settings.ExportToEmailEmailFrequencyPositionKey, Settings.ExportToEmailEmailFrequencyPositionDefault); switch (frequency) { case 0: Preferences.Set(Settings.ExportToEmailNextEmailForKey, nextScheduledEmailDate.AddDays(1)); break; case 1: Preferences.Set(Settings.ExportToEmailNextEmailForKey, nextScheduledEmailDate.AddDays(7)); break; case 2: Preferences.Set(Settings.ExportToEmailNextEmailForKey, nextScheduledEmailDate.AddDays(30)); break; } }

This is the code that will run forever

private async void SendStatisticsToEmailBySchedule()
        {
            do
            {
                if (MyData.Count != 0)
                {
                    var currentConnectivity = Connectivity.NetworkAccess;
                    NextScheduledDateForReport = Preferences.Get(Settings.ExportToEmailNextEmailForKey, CurrentDateSettings.ExportToEmailNextEmailForDefault);

                    if (DateTime.Now > NextScheduledDateForReport)
                    {
                        if (currentConnectivity == NetworkAccess.Internet)
                        {
                            try
                            {
                                SendStatisticsToEmail(Preferences.Get(Settings.ExportToEmailSubjectKey, Settings.ExportToEmailSubjectDefault),
                                    Preferences.Get(Settings.ExportToEmailServerAddressKey, Settings.ExportToEmailServerAddressDefault),
                                    Preferences.Get(Settings.ExportToEmailPortKey, Settings.ExportToEmailPortDefault),
                                    Preferences.Get(Settings.ExportToEmailFromKey, Settings.ExportToEmailFromDefault),
                                    Preferences.Get(Settings.ExportToEmailToKey, Settings.ExportToEmailToDefault),
                                    Preferences.Get(Settings.ExportToEmailUseSSLKey, Settings.ExportToEmailUseSSLDefault),
                                    true,
                                    Preferences.Get(Settings.ExportToEmailUsernameKey, Settings.ExportToEmailUsernameDefault),
                                    Preferences.Get(Settings.ExportToEmailPasswordKey, Settings.ExportToEmailPasswordDefault)
                                );
                            }
                            catch
                            {

                            }
                        }
                    }
                }
                await Task.Delay(21600);
            } while (true);
        }

From what I've read here: https://developer.android.com/guide/components/services#Choosing-service-thread If you only want to run code while the user is using your app, you shouldn't be using a service.

Is my code on? SendStatisticsToEmailBySchedule () efficient?

Is there a situation that no longer works or should I somehow check if it still works?

api – endless loop in bidirectional relationship – ManyToMany

I am creating a residual API in SpringBoot. In it I have 2 classes that are related and when I get one of them they return an endless loop through their foreign keys

I tried to use fetchType.Lazy but with no results.

They refer to an article because this category comes from a later project.

user class

@Entity
@Table(name = "tb_user")
public class UserListed {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "cd_user")
private Long id;

@Size(max = 50)
@NotBlank
@Column(name = "nm_user")
private String name;

@Size(max = 21)
@NotBlank
@Column(name = "nm_username", unique = true)
private String username;

@Size(max = 120)
@NotBlank
@Column(name = "nm_email", unique = true)
private String email;

@Size(max = 255, min = 8)
@NotBlank
@Column(name = "nm_password")
private String password;

@Size(max = 120)
@Column(name = "ds_biography")
private String biography;

@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "category_user",joinColumns = 
    {@JoinColumn(name = "cd_user")}, inverseJoinColumns = 
    {@JoinColumn(name = "cd_category")})
private List categories;
// get e set

class category

@Entity

@Table (name = "tb_category")
public class category {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "cd_category")
private Long id;

@Size(max = 24)
@NotEmpty
@Column(name = "nm_category")
private String name;

@ManyToOne
@JoinColumn(name = "cd_project")
private Project project;

@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "category_user", joinColumns = 
        {@JoinColumn(name = "cd_category")}, inverseJoinColumns  =
        {@JoinColumn(name = "cd_user")})
private List users;
//get e set

Return:

{
    "id": 9,
    "name": "greatcode",
    "username": "@greatcodeGC",
    "email": "greatcode.gc@gmail.com",
    "password": "$2a$10$pIYyhZo/iUKtq99g.Mbl1eYns/ABQddhFxvxDIeZ/Id2JFra9xBNO",
    "biography": "Uma empresa criada por jovens estudantes de TI",
    "categories": (
        {
            "id": 2,
            "name": "ScrumMaster",
            "project": null,
            "users": (
                {
                    "id": 9,
                    "name": "greatcode",
                    "username": "@greatcodeGC",
                    "email": "greatcode.gc@gmail.com",
                    "password": "$2a$10$pIYyhZo/iUKtq99g.Mbl1eYns/ABQddhFxvxDIeZ/Id2JFra9xBNO",
                    "biography": "Uma empresa criada por jovens estudantes de TI",
                    "categories": (
                        { ...

Unity – I've seen a tutorial about an endless runner game like subway surfers, but when I try to spawn tiles, it doesn't spawn in the correct position

Hello everyone, I'm new here and also in game development. I watched a tutorial on endless runner game like subway surfers, but when I try to spawn tiles it doesn't spawn in the correct position. Here is my code:

    public class TileManager : MonoBehaviour
    {
        public GameObject() tilePrefab;
        public Transform playerTransform;
        private float spawnZ = -6.0f;
        private float tileLength =-12.0f;
        private int amnTilesOnScreen = 7;
        private List activeTiles;
        // Start is called before the first frame update
        private void Start()
        {
            activeTiles = new List();
            playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
            for(int i=0;i(spawnZ-amnTilesOnScreen * tileLength))
            {
                SpawnTile();
            }
        }
        private void SpawnTile(int prefabIndex=-1)
        {
            GameObject go;
            go = Instantiate(tilePrefab(0)) as GameObject;
            go.transform.SetParent(transform);
            go.transform.position = Vector3.forward * spawnZ;
            spawnZ += tileLength;
            activeTiles.Add(go);
        }
        private void DeleteTile()
        {
            Destroy(activeTiles(0));
            activeTiles.RemoveAt(0);
        }
    }